Meteor Basics: Display Information about specific user in profile page - meteor

I'm using React and Meteor.
I have a form that allows a user to register. When a user registers, he/she enters info such as their bio, facebook url etc etc. I use Accounts.createUser to register.
When a user visits /user/:userId, I want to display the info about the user with id userID.
I am totally lost on how to combine this with withTracker, and if withTracker is even necessary.
import React, {Component} from 'react';
import {withTracker} from 'react-meteor-data';
class Profile extends Component {
render() {
return(
<div>
<p>Username: </p>
<p>Bio: </p>
</div>
);
}
}
export default Profile;
Where do I go from here? I took a look at this https://guide.meteor.com/react.html#introduction
but honestly I don't get it.
I guess my questions are:
1. How do I set up a subscription to Meteor.users? (I removed autopublish and insecure)
2. .... How do I pass the data into the profile container?

You need neither subscribing to Meteor.users nor implementing withTracker, as Meteor.user is already a reactive data source and managed by Meteor.Accounts not via pub/sub. You should read official Meteor Users Accounts page, first. I also advice you to exercise Meteor & React simple tutorial.

Related

New export action for pages in magnolia cms

I need to create a new export action for the page app in magnolia cms that would always export selected page elements to a YAML file.
I would like to override the class definition and the dialog definition for the existing export action since I do not need a dialog that lets me select YAML or XML. It will always be YAML in my case.
I setup a new Maven module and created a new action for the Page app.
How do I configure a custom class for this action? How do I get the current context of the page in my class?
You have to remove the dialog attached to the action first. If you plan to have a custom action then simply do not configure one. We already have two actions for those two cases. If you are interested in YAML export use the following: info.magnolia.ui.framework.action.ExportYamlAction
My action configuration for exportYAML2
My actionbar configuration for exportYAML
* repeating the content of the comment below since I could not post pictures in the comment *
I configured two actions for exporting the YAML configuration of the node.
The second one (exportYAML2) using ExportYamlActionDefinition does not show up in the actionbar for the page even though I added it as an item.
Is there anything else I need to configure for it?
exportYaml with class info.magnolia.ui.framework.action.OpenExportDialogActionDefinition works. exportYaml2 with class info.magnolia.ui.framework.action.ExportYamlActionDefinition doesn't work. Availability for it is set to info.magnolia.ui.framework.availability.IsNotDeletedRule.
It is solved.
There are two things I needed to configure for a custom action in the pages app in magnolia.
configuration app modules>pages>apps>pages>subApps>browser>actions>MyAction withe class={custom or common class from https://documentation.magnolia-cms.com/display/DOCS61/Action+definition }
modules>pages>apps>pages>subApps>browser>actionbar>sections>pageActions>groups>uniquegroupname>items-MyAction

How do I add custom dimensions to Google Analytics with React Router?

My current analytics setup looks like this:
this.context.router.listen(location => {
analytics.page(location.pathname, {
title: document.title,
url: `${config.HOST_URL}${this.context.router.createHref(location)}`,
path: this.context.router.createHref(location),
referrer: document.referrer,
state: location.state,
});
});
The amount of data in the location object is pretty minimal. The question is, how do I get information about an item that is loaded in a componentDidMount block into the page tracking?
In this particular instance, I am trying to add information about an artwork that a user is looking at into Google analytics as a custom dimension. The link below shows how it would normally be added.
https://support.google.com/analytics/answer/2709828?hl=en#example-hit
I'm using react-router v2
From the information given, I'd say your best bet is on the pages you want to add more data put a condition in the listener to NOT log if loading that page. Then in the componentDidMount where you have the data call the analytics for the page.
Basically just override it for those pages that need more data.

How can I make Meteor templates available to targeted audiences via an URL?

I want to build a Blog, of sorts, with Meteor but, rather than just have a Blog such as platypus.meteor.com, I want to create a separate Meteor template for each Blog "post" and then send a link to select people such as "platypus.meteor.com/thispost"
In this way, the person would only see the post I intend them to see; to see others, they would have to guess at other values, such as "/thatpost", "/theotherpost" etc.
And in my case, if they stumbled across them, no big deal.
This is my plan:
Create one template at a time:
<template name="thispost">
. . .
</template>
...and then allow access to that to whomever I apprise of its availability (that is, they simply enter the link I send them into their browser).
I don't know what sort of routing I need to set up; I'm open to either IronRouter or FlowRouter. At any rate, I want an URL like "platypus.meteor.com/thispost" (after a "meteor deploy platypus" of this project) to show the user the contents of that Template and nothing else.
So my question is: what do I have to do, routing-wise, to accomplish this?
How about simply:
Router.route("/:templateName/:postId",{
template: this.params.templateName,
data: function(){ return Posts.findOne({ _id: this.params.postId })
});
Then you can generically share any post with any template and have the template name appear right in the route.

How to `load dynamically page` in same template using `meteor js`

I need how to load dynamically page loading in same page using meteor js.I will develop for Admin panel ,after login Admin display admin details dynamically with same template page.
You can put the details in a conditional:
<template name="example">
{{#if admin}}
Admin details
{{/if}}
</template>
Template.example.admin = function() {
return Meteor.user() && Meteor.user().admin;
};
I'd suggest you use routes for this. This also allows you to control what other users see when they aren't admin and redirect, etc. instead of using a crazy number of conditional statements. For an example of an admin interface that is actually added via a smart package, see the following files, which use iron-router:
https://github.com/HarvardEconCS/turkserver-meteor/blob/master/admin/clientAdmin.html
https://github.com/HarvardEconCS/turkserver-meteor/blob/master/admin/clientAdmin.coffee

How do I add extra fields (custom captcha) to the registration form in Plone 4.1

I am trying to add a custom captcha to the registration form for my Plone site. I recently upgraded from 3.1.x to 4.1.3 and this broke my existing customizations to the join_form template and validation script.
I have been trying to follow the collective.examples.userdata example to make my customization. I think I have followed the example correctly but the new field is not being rendered into the registration form.
How do I figure out why the extra fields are not showing up and is there a better way to add a custom captcha to the form?
Note that I did try looking at one of the captcha packages for Plone 4 but the the ones I looked at seemed really complicated (one had parts strewn across 3 packages).
Update: Apparently using the stock collective.examples.userdata doesn't work for me either. I add the collective.examples.userdata and I don't get any additional fields on the ##register form.
Also, I am using the old plone 3 fallback template if it makes a difference.
This example uses the excellent quintagroup.formlib.captcha widget, but the general approach can apply to many other situations.
Basically, you do not want to define a captcha field in your user data schema; rather, you want to temporarily add it to the form schema when you render the form, in this way:
browser/interfaces.py
from zope.interface import Interface
from quintagroup.formlib.captcha import Captcha
from my.package import myMessageFactory as _
class IMyRegistrationForm(Interface):
"""Marker interface for my custom registration form
"""
class ICaptchaSchema(Interface):
captcha = Captcha(
title=_(u'Verification'),
description=_(
u'Type the code from the picture shown below.'
),
)
browser/forms.py
from zope.formlib import form
from plone.app.users.browser.register import RegistrationForm
from quintagroup.formlib.captcha import CaptchaWidget
from my.package.browser.interfaces import IMyRegistrationForm, ICaptchaSchema
class MyRegistrationForm(RegistrationForm):
""" Subclass the standard registration form
"""
implements(IMyRegistrationForm)
#property
def form_fields(self):
# Get the fields so we can fiddle with them
myfields = super(MyRegistrationForm, self).form_fields
# Add a captcha field to the schema
myfields += form.Fields(ICaptchaSchema)
myfields['captcha'].custom_widget = CaptchaWidget
# Perform any field shuffling here...
# Return the fiddled fields
return myfields
Finally, register your custom registration form in browser/configure.zcml:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="my.package">
<browser:page
name="register"
for="Products.CMFPlone.Portal.PloneSite"
class=".forms.MyRegistrationForm"
permission="zope.Public"
/>
</configure>
Tested using collective.examples.userdata and Plone 4.1
I don't know the best answer, but it's been discussed at http://comments.gmane.org/gmane.comp.web.zope.plone.user/115264 if you've not already found that.

Resources