-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Piwik DSL #10
Comments
Sounds like a good and clean interface. 👍 Thing is, though, in most situations, I'd consider the controller to be the best place to set these variables; they will need to pass them onto the view anyway in order to set them there with your proposed You state that
Which implies you already thought about this issue too :) The way I started implementing the setters in the controllers is by proxy-ing everything trough a generic
Controllers can then set any attribute on the tracker:
(*) I don't know if in Rails This was my idea, anyway. But I am not too familiar with the proper patterns in a rails engine, so it might just be plain stupid alltogether :) |
Oh well, the text was just a copy&paste from the other ticket. Just wanted to have a separate ticket. The way you implemented it is exactly how I imagined it. I still have some local changes where I have a similar implementation which is available is both controller and view. I'll commit the changes next week, just need to find a good way to generate Javascript function calls out of it. E.g.:
should automatically transform to
My implementation works by defining two helper methods, one for the controller and one for the view (both share the same PiwikTracker object). In the controller the helper will work as a configuration utility
The view helper works as shown above and allows you to access the configuration (in the block). It will then transform the PiwikTracker object to JavaScript calls. |
is somewhat of an issue. Specified the API in a huge data structure for now. If you know some better way to do this, let me know. method_missing is used to check whether a method exists, validate the arguments and add it to list. The list will be converted to valid JS calls (based on use_async?) and rendered out for piwik_tracking_tag. refs #7, #10
@berkes, did you have time to look at the implementation? I'm thinking of just implementing all methods manually instead of using ruby meta programming to generate them on-demand. |
Sadly (or, actually not :) I did not have time to look at it before my holidays. I will implement it once I get back in the first week of May. |
Right now I am working on an extension for the view helper to provide access to the JavaScript Tracking API.
It might look like this:
This will output JavaScript for both tracking options (async/sync). If you have any comments on this implementation I'd be happy to hear them. I am not quite sure how to make this accessible via the controller, but I'll figure something out.
refs #7
The text was updated successfully, but these errors were encountered: