
david at kineticode
Jan 17, 2011, 10:52 AM
Post #2 of 52
(5287 views)
Permalink
|
On Jan 17, 2011, at 12:17 AM, Zdravko Balorda wrote: > I've just pushed an update to Bricolage github regarding Bricolage > wywsiwyg inteface. Bellow is a short report on what things are about. > > Be critical, please. :) Thanks for sending this, Zdravko. > This is a report on changes made on Bricolage to provide > its wysiwyg interface, written for repository maintainers. > > This interface provides for passing Bricolage internals to > Java applets, namely ckeditor. I'm confused. Isn't it a JavaScript editor? I just loaded the demo here: http://ckeditor.com/demo I don't see any java there…am I missing something? > While editing a story in story profile the wysiwyg editor > is now aware of all releated documents attached to the story. > It's done via Java array variables, namely: > > var related_images; > All related media documents of MIME type image/* > > var related_nonImages; > All related media of MIME type NOT image/* and all related > story documents > > var related_objects; > All related media documents of MIME type: video/*, audio/* > and application/x-shockwave-flash. > > A call to: > <& '/widgets/wysiwyg/bricolage-wysiwyg.mc' &>; > returns a hash containing Java source strings that are assigned to > Java variables from two files: > comp/widgets/wysiwyg/load.mc > and > comp/widgets/wysiwyg/container.html > > The first declares the hash keys as arrays: > > <script type="text/javascript"> > % my %java_vars = $m->comp('/widgets/wysiwyg/bricolage-wysiwyg.mc'); > % foreach my $key_name (keys %java_vars) > % { > var <% $key_name %> = <% $java_vars{$key_name} %>; > % } > </script> If it is JavaScript rather than Java, as it certainly appears, just stylistically I'd prefer better variable names. But you can also do this a bit more expressively: <%perl>; my %config = $m->comp('/widgets/wysiwyg/bricolage-wysiwyg.mc'); while (my ($k, $v) = each %config) { $m->print("var $k = $v;\n"); } </%perl> > while the file container.html merely redefines their values at > page reload. Since container.html also reinitializes ckeditor the > editor is aware if an element is deleted or a story is saved from > story profile. > > Perhaps I pushed the issue of generality a bit too far here. > /widgets/wysiwyg/bricolage-wysiwyg.mc is supposed to be a single > entry point between Bricolage and external Java applets like ckeditor. > Please, feel free to repack things or let me know. Okay. > conf/bricolage.conf > > Bricolage configuration have two new parameters: > # A comma or space separated list of key names of related documents element > # types e.g. related_media, related_exponat > # RELATED_MEDIA_TYPE_NAMES = related_media > # RELATED_STORY_TYPE_NAMES = related_story, linked_news > > Deafult values are related_media and related_story. This is a bit of > hack, because get_elements() wants one or more strings as arguments > that cannot be directly passed as constants. I don't understand why these are required. You can look at individual elements to tell if they're related via the `can_relate_story()` and `can_relate_media()` methods. > CKeditor > > CKeditor is good as it comes. Addittional fields to Image, Link and > Flash plugins are defined externaly via ckeditor API. This, other, end > of the interface is contained in ckeditor.html. Porting this code to > other editors would provide the same functionality. Nothing else needs > to be changed. Nice. We do already have FCKEditor support. How does this relate to CKeditor? Is FCK deprecated? Should we drop it in favor of CK? > Users now have an option to select a media from a list instead of > linking html tags to hard URLs. When selected other fields got populated, > typically alt and title attribute of the appropriate tags. Sounds great. > I have stripped quite a lot of tools from the editor. I don't feel > that much should be left to users in CMS. No font sizes! One can and > should use <small> or <big> but, that's it! God forbid changing fonts. +100 # I'm philosophically with you, brotha. > I have left out also SpellChecker and Scyt which may be usefull if > working. What's required? What is Scyt? > preview/media/dhandler > > The editors goes after their URIs to provide for wysiwyg media preview. > Here, the URI would be of the form: > /preview/media/$uuid > > There is new /preview/media/dhandler that returns the media file according > to the $uuid embedded in the calling URI. Nice. > Template > > The URIs in html tags <img>, <a>, and <object> are saved in a story > as: > /preview/media/$uuid > This needs to be processed by story template. Here is a simple suggestion: > > % sub bricolage_wysiwyg { > % my @media = $element->get_elements('related_media'); > % my @stories = $element->get_elements('linked_news'); > % my (%uuids); > % foreach my $rm (@media) { > % my $md; $md = $rm->get_related_media(); > % $uuids{$md->get_uuid} = $burner->best_uri($md) if $md; > % } > % foreach my $rs (@stories) { > % my $st; $st = $rs->get_related_story(); > % $uuids{$st->get_uuid} = $burner->best_uri($st) if $st; > % } > % s|(/preview/media/[\w\d\-]+)|$uuids{substr($1,15)}|g; > % return $_; > % } > > The subroutine call > $story_text = bricolage_wysiwyg($story_text); Erm, don't really follow what this is about… > rewrites all tags entering correct URI for every html tag. A nice > thing about it is that when a story is republished, html tags will be > rewritten accomodating for any possible change in document URIs. Oh, so the HTML stored from CKEditor will have something like /preview/media/$uuid in it? Is there no way around that? > BUGS > - any changes to story profile are visible to the editor by reloading > the story profile page. It is ok for deleting an element and > "Store and Stay", but, ckeditor is not aware of changes made by > editing a subelement. This needs to be done via AJAX in lib/js/lib.js > and is too deep for my knowledge of Java. Help needed. Sure, simply editing an element never affects previews or other elements until you save or save and stay. There is no Ajax submission if you just edit an element. But if you delete one or add a new one, all of them are reloaded, and changes should show up then. Is that the case? Best, David
|