Hello all. John had asked me to create this some time ago as a
proof-of-concept for an enhancement to the core of Radiant. Well, it’s
finally here and I would appreciate any and all feedback (directly or on
the mailing list) to improve this.
Note: this is a Rails 2.x/Radiant 0.6.6 extension and it won’t work with
previous versions.
What it Does
Adds Stylesheet and Javascript objects to Radiant. It should be very
self explanatory to use but it has some real benefits (like its own
caching mechanism to speed up server responses). Check out the README
file for a list of features/benefits and usage.
Where to Get It
I’m not running on git so you get to use good 'ol svn:
https://secure.svnrepository.com/s_swanki/open/radiant/extensions/styles_n_scripts/tags/v0.2
Thanks and enjoy!
Chris P.
Swank Innovations, LLC
This looks very nice Chris.
Instead of calling the tabs “CSS” and “JS” why not “Styles” and
“Scripts”? (Seems appropriate considering the name of the plugin.)
I’m getting an ActionController::InvalidAuthenticityToken exception on
the O.6.7 when I try and submit a form.
I’m also getting a undefined method `updated_by’ for #<Javascript:
0x236d6c8> on 0.6.6 when I try to edit a javascript that I just created.
Have you taken a look at the prototype directory in trunk? We have a
working HAMl prototype there that you can play around with using serve.
–
John L.
http://wiseheartdesign.com
John W. Long wrote:
This looks very nice Chris.
Instead of calling the tabs “CSS” and “JS” why not “Styles” and
“Scripts”? (Seems appropriate considering the name of the plugin.)
Thought about that. Just trying to be considerate of other extension
developers by conserving tab space
Also we had entertained the idea of putting the two items inside one tab
at one time (and even putting them all together with images onto an
“assets” tab). Anyway, I wasn’t too focused on any one name for now.
I’m getting an ActionController::InvalidAuthenticityToken exception on
the O.6.7 when I try and submit a form.
Dude, I released this before 0.6.7. Man, tough crowd
I haven’t loaded 0.6.7 yet – I’ll look into it.
I’m also getting a undefined method `updated_by’ for
#<Javascript:0x236d6c8> on 0.6.6 when I try to edit a javascript that
I just created.
Thanks. Looks like a last minute change + no spec coverage on view
(yet) = sloppy programmer.
I’ll look into that too.
Have you taken a look at the prototype directory in trunk? We have a
working HAMl prototype there that you can play around with using serve.
Not yet. I remember you mentioning something about that idea several
months back – glad to see it launched. Sounds slick.
-Chris
On 5/17/08, Chris P. [email protected]
wrote:
it seems to wipe out the existing observation of Page, Snippet, etc.
I had this same issue some time ago and you can take a look at how I
fixed it here:
http://mgr.devjavu.com/browser/audioguide/vendor/extensions/forum/forum_extension.rb#L34
Does anyone know how to append classes to UserActionObserver? I’d
like to fix this issue but if I have my extension’s activate method call:
UserActionObserver.observe Stylesheet, Javascript
Yes, for some unknown reason, observe redefines the “observed_classes”
method instead of changing a class variable. Go figure.
I would do something like this:
new_classes = UserActionObserver.instance.send(:observed_classes) +
[Stylesheet, Javascript]
class << UserActionObserver.instance
define_method :observed_classes { new_classes }
end
Not sure about the scoping on that, etc, but that’s the general outline.
Sean
I like your solution better, Martins.
Sean
I fixed the issue mentioned below. The updated version can be found at:
https://secure.svnrepository.com/s_swanki/open/radiant/extensions/styles_n_scripts/tags/v0.2.1
This fix solves the error but still does not properly register the
created_by_id and updated_by_id fields in Stylesheets and Javascripts
(which was tied to the source of the original error).
Does anyone know how to append classes to UserActionObserver? I’d like
to fix this issue but if I have my extension’s activate method call:
UserActionObserver.observe Stylesheet, Javascript
it seems to wipe out the existing observation of Page, Snippet, etc.
The 0.6.7 issue will have to wait another day…
-Chris
Could someone work up a patch for this issue.
–
John L.
http://wiseheartdesign.com
Thanks for the quick responses you two. I’ll be able to look at things
this evening and hopefully be able to add a few new specs and the code
you so wonderfully provided.
I’ll also take a look at the 0.6.7 error that John mentioned.
BTW, if any of you know (or think you know) what’s up with that one,
feel free to send some guidance. (I haven’t even downloaded 0.6.7 yet
so I haven’t seen the issue myself).
-Chris
Sean, I got an attachment but it looks to only contain the mailing list
email footer. Is the mailing list server whacking attachments possibly?
Could you send it to me directly or perhaps paste it into the body if
you want to share it with all…
Thanks,
Chris
Chris,
See attached patch. Extension developers – if you aren’t using the
built-in form helpers in your views, please switch to them. They will
automatically add the proper authenticity token to the form for you.
Sean
I could get it run on a clean install (0.6.7) tho, with sqlite3 and no
other extension installed
it gives Could not find table ‘config’ error
On 5/18/08, Chris P. [email protected]
All of the aformentioned bugs have been squished (with thanks going out
to MÄrtiņš and Sean for the exceptional help). The latest tag of the
Styles 'n Scripts extension can now be found at:
https://secure.svnrepository.com/s_swanki/open/radiant/extensions/styles_n_scripts/tags/v0.2.2
It runs on Radiant 0.6.6 and 0.6.7 so far.
-Chris
I think this is a fault of Radiant. Could be wrong.
nurullah wrote:
I could get it run on a clean install (0.6.7) tho, with sqlite3 and no
other extension installed
it gives Could not find table ‘config’ error
On 5/18/08, Chris P. [email protected]
although all installation steps fail it adds tabs on panels and some
columns
on config table
5|stylesheet_mime_type|text/css
6|response_cache_directory|text_asset_cache
7|javascript_mime_type|text/javascript
8|javascript_directory|js
9|stylesheet_directory|css
but you are right production.log says it cannot find text_assets table
and
right there is no such table on db file
On 5/19/08, Chris P. [email protected]
Ok, so now that you have a running Radiant app, you now should do the
following to install the extension:
-
Copy the Styles 'n Scripts Extension to the following path:
radiant_app/vendor/extensions/styles_n_scripts
You can find the latest version of the extension here:
https://secure.svnrepository.com/s_swanki/open/radiant/extensions/styles_n_scripts/tags/v0.2.2
-
From your radiant_app directory, migrate the extension’s db
changes (adding the text_assets table). Run:
rake radiant:extensions:styles_n_scripts:migrate
If you have any problems, run the rake task with the '--trace'
option to show the details (and post them here).
-
Finally, copy the images used by the extension. Again, from your
radiant_app directory, run:
rake radiant:extensions:styles_n_scripts:update
This doesn’t sound like where your problem lies but, if you should
have any problems here, run rake with the --trace option again.
Good luck and let us know how it goes and post any specific error
messages here.
-Chris
-
nope that gave the same config error…
but this way it worked charmly… thank you
rake RAILS_ENV=“production” radiant:extensions:styles_n_scripts:migrate
rake RAILS_ENV=“production” radiant:extensions:styles_n_scripts:update
p.s.: uncommenting ENV[‘RAILS_ENV’] ||= ‘production’ on
config/enviroment.rb
dont help
-
is there any way to call js/css files from anywhere of the page/layout?
suppose, i use one template and many subpages?
but i use different/extra css/js files on subpages (and also common),
for
example i will use accordion script on a subpage and putting this on
template or on header snippet is nonsense
so i am looking for a way to call these files from inside page/layout
The Styles 'n Scripts extension makes use of Radiant’s built-in
Radiant::Config settings (which get stored in the config table). So
this sound like a Radiant setup issue. (The only table my extension adds
is text_assets).
Remove my extension (all extensions, really) and make sure that your
plain-vanilla Radiant extension has this table created (should have been
created when you ran:
rake db:bootstrap (or rake production db:bootstrap if running in
production mode).
-Chris
is there any way to call js/css files from anywhere of the page/layout?
suppose, i use one template and many subpages?
but i use different/extra css/js files on subpages (and also common), for
example i will use accordion script on a subpage and putting this on
template or on header snippet is nonsense
so i am looking for a way to call these files from inside page/layout
The way I usually do this is to put a content part in my layout’s
header called “head-meta” that appears in the header, e.g.
...other header stuff ...
Then you can just add a part to the page called (what else) head-meta
and add whatever page-specific Javascript, CSS, meta tags, etc. you
might want.
Hope this helps!
Rufo
I played around with the idea of creating an <r:stylesheet> and
<r:javascript> tag or even enhancing the <r:content> tag to let you add
stylesheet/javascript content in addition to page part content.
The problem is that in either case you have to specify which file you
want (either explicitly or by first setting up a context to that item)
so why not just manually type it and save the noise of yet another
radius tag.
This case, however, has me thinking the other way. (Plus the other
benefit that your users only need to know the name of the script or
stylesheet and not their full path – my tag would build that).
I’m going to be putting out a new rev shortly – it would be simple to
add a <r:stylesheet> and <r:javascript> tag.
I’d certainly welcome other ideas as well.
-Chris