Active
Project:
Clipped.me
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
1 Feb 2013 at 19:24 UTC
Updated:
8 Feb 2013 at 12:44 UTC
Jump to comment: Most recent file
Meh, just a thought - feel free to ignore or discuss :o) Drupal is moving away from hard drupal_add_css/_js calls and onto render arrays (of doom *cough*), anyways - the idea is that instead of using the standard drupal_add_js calls for example, we go to using (in hook_page_alter);
$page['content']['#attached']['js'][] = $plugin_path . '/src/jquery.poshytip.min.js';
Obviously it can be whatever it needs to be (content/ header/ footer/ etc) and it allows for easier override from other places.
Thanks again for a great little module!
Pobster
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | clippedme-Drop_hook_init_for_hook_page_build-1905682-9.patch | 2.54 KB | Drave Robber |
| just-a-thought.patch | 3.42 KB | pobster |
Comments
Comment #1
pobster commented...I made a couple of other small adjustments as well - all minor.
Thanks,
Pobster
Comment #2
Drave Robber commentedThese adjustments make sense; none are urgent though, so I'm going to deal with them one-by-one.
One thing I'm not quite sure of is
exitvsdrupal_exit(); that local proxy thing is "not really a page", and implementations of hook_exit() mostly do not seem relevant or welcome there. (Seeingstatistics_exit()on that list gives some interesting thoughts, however.)Comment #3
Drave Robber commentedCommitted the first step - doing away with clippedme_branding(). (I initially thought it might have more to do, but a separate function for getting just one URL is a sort of overkill.)
Comment #4
pobster commentedAgreed that it's not a page but it is still a callback in the sense that say, an ajax autocomplete is a callback, isn't it relevant for e.g. that statistics hook to fire to count the number of times that callback is fired? It's a backend call which can't be cached with Varnish, it's kind of useful to know that page is being hit x number of times?
I was taking my lead from http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_e... which states "There should rarely be a reason to call exit instead of drupal_exit();" - I do however agree with what you're saying... TBH though, neither approach is how Drupal is supposed to do it! We're supposed to implement "delivery callback" in hook_menu() (for reference see ajax_deliver or wysiwyg_deliver_dialog_page for a perhaps neater one). I myself think this is absolute balls though... I don't see why every module needs to implement their own ajax-type delivery callback, it makes no sense?! Why isn't this already in core?! Anyways, if you're interested in this approach then this is one I wrote last year sometime;
(edit)
And then call it using;
(edit)
I think you're right though - ignore this one! And thanks, I enjoy the discussion! :o)
Thanks,
Pobster
Comment #5
Drave Robber commentedNow that I think of it, there actually is ajax_deliver(). What it does is probably mostly redundant for delivering a simple JSON though. Having a custom delivery callback that cuts it down to bare minimum seems a promising idea - thanks for it!
Comment #6
pobster commentedYeah
ajax_deliver()is really geared towards forms (and only for forms I'd say, I agree there's far too much going on), it's a shame there isn't anything nice and lightweight for simple RESTful JSON responses. I guess that's one of the things driving D8 forward (http://groups.drupal.org/node/226479).Don't discount the change from
hook_init()tohook_page_alter()BTW, the change to renderable content arrays allows other modules to alter the content array if they need to. When it's all hardcoded intohook_init()there's nothing they can do except hack the module.Thanks,
Pobster
Comment #7
Drave Robber commentedNot discounting it, quite the opposite - that particular change is going to be accepted without much discussion.
Just that I prefer small, incremental one-thing-at-a-time microcommits - the progress might be slower but when something breaks it's easier to debug.
Comment #8
Drave Robber commentedCommitted: removed redundant wrappers on $data (cruft left over from the early stage of development); cid doesn't really need to be passed around.
Comment #9
Drave Robber commentedDoes this look good enough? Changes compared to your initial patch:
hook_page_build()instead ofhook_page_alter()- so that modules wishing to mess with this inhook_page_alter()wouldn't have to worry about weights;'scope' => 'footer'- they're unlikely to be needed before page is fully loaded;$page['content']- CSS and js isn't going to stay there anyway so this is purely formal.Comment #10
pobster commentedYep looks good to me! :o)
Thanks,
Pobster
Comment #11
Drave Robber commented#9 committed.
alpha3 should be out shortly. (new release because of #1911686: Not working for sites using non-latin alphabets)