Live comment preview

Creating and modifying plugins.
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

You are right.
The existing script didn't worked for me, so I only used parts of the .php. Because of your post I examined it further, it is working better than I thought. You have to click on the textbox. How weird.

I'll try to combine.
Greets
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

A short update:
I failed in adding the jquery-approach approach to the existing livecomment-plugin. It is very easy to change the event-handler to update the preview instant - but this creates flickering and is laggy. Probably the ajax-call is really too performance-intense. Maybe there are ways to workaround these issues, but I don't know how.
Simply adding the jquery-code on top of the existing functionality failed, I think that the event-handler can't be combined that easily.

Cause of that failure I tried the other way and added format-support to the jquery-approach. Serendipity- (partly), bbcode- (partly), markdown-, textile- and nr2br-markup-simulation are already implemented (most of them already existed). The settings of the blog are taken in account: it will only format the preview in a specific markup if you enabled it generally for the comments.

Please give me a hint if you know other existing javascript-parser for markup-languages which may be enabled in serendipity.

More info in german and the opportunity to test the plugin live (only serendipity-markup and nl2br enabled) here, Download.
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

Well, I'm a bit surprised there comes no feedback. The functionality now equals the Wordpress live-preview-plugin, as there now is an instant preview. Wasn't that requested?

Test and download of current version can be found here.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Sorry, this live previewing was a thing I only did for experiments initially. When I got loaded with work I had no opportunity to look into you rdevelopments.

Today I was able to.

I committed your plugin, but I merged it with the existing livecomment plugin, so that a user can now choose between your method and mine. Both methods have drawbacks and advantages, so I decided to allow both. I also took the liberty to improve your plugin in terms of markup checking, and improved my old code to better work with bulletproof templates and improved the overall handling so that it's now more usable.

I'm interested in what you think! I committed the update to Spartacus, so it should be contained tomorrow on spartacus.s9y.org - or you fetch it via CVS manually.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

I also took the liberty to improve your plugin in terms of markup checking, and improved my old code to better work with bulletproof templates and improved the overall handling so that it's now more usable.
Sounds great. I look forward to see your changes. Will give you feedback as soon as I can.
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

Your changes are indeed improvements. Great work! Think everything is alright, works as intended. Two (minor important) things are left to do:
  • Translation of the menu (already did this for german, how do i commit the files properly? Upload them and send you the links?)
    Translation of the headline "Live-Vorschau". Only way I see is working with "globals" like with the activation of the specific markup-parsers. If you agree with that method I'd implement it, if you don't want to do it yourself.
Edit: Found a bug. The rss-feed of the comments ain't working no more. It's a bug I also ran into, but I don't actually see how I fixed it -.-

Edit2: Got it. You moved the markup-check to 'fetchomments', but cause of the Bug I think it has to be in 'frontend_comment'. It would fix the rss-feed.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

In which case does the rss feed no longer work, with which kind of error? Only in the "legacy" mode, only in "jquery" mode or in both? Basically I think it should work?!

About translation: Yes, the string variables would need to be passed on like globals to the javascript output.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

In jquery-mode. The feed no longer works because the plugin writes <script>bb= true</script> into the feed, which breaks the compatibility.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Ah, I didn't properly check that, good catch. I just committed an update!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

Thanks, problem fixed.
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

I added the english translation of the title (and a german translation for the menu). It's uploaded here.
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

Writing the javascript-variables in the head seemed too ugly, especially when thinking about new options which all would polute the head-section. So I implemented an ajax-call which grabs the config. Don't know how performance-intense that is but here it seemes to work well and fast.
Also changed fade-in timings and added a fade out to 75% when unfocusing the textfield. With the new method to check the config I think the next step should be adding customization-options. The changes from the last version (german translation and translated preview title) are integrated.

Download of a .tar.gz, will provide a diff if requested.


PS: Had a fight with the php-array which didn't want to get bigger when adding the title-string (PLUGIN_EVENT_LIVECOMMENT_PREVIEW_TITLE) manually, so I had to use a function with the only purpose to echo the string. Weird and very ugly. Looking forward to see the solution :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, the performance costs are actually really existing. It means calling the whole s9y framework a second time. if you emitted it during frontend_header, the framework would already be there. Since the javascript is emitted on every page, it surely increases the load time of every page about 30-40%.

But if you think that's worth it...I committed your patch.
PS: Had a fight with the php-array which didn't want to get bigger when adding the title-string (PLUGIN_EVENT_LIVECOMMENT_PREVIEW_TITLE) manually, so I had to use a function with the only purpose to echo the string. Weird and very ugly. Looking forward to see the solution :)
What exactly do you mean there? Your "get_title" PHP function does not seem to be called anywhere?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Post by onli »

Wow. 30-40% is really much. I don't know if that's really worth it - even though I think it's a more useable solution and having such javascript-parts in the head really annoys me.

Used the function in line 100:

Code: Select all

 case 'reallivecomment':
                            $markups =& $this->get_markups();
                            $data = array($this->check_markup($markups, 'serend$
                                      $this->check_markup($markups, 'serendipit$
                                      $this->check_markup($markups, 'serendipit$
                                      $this->check_markup($markups, 'serendipit$
                                      $this->check_markup($markups, 'serendipit$
                                      $this->get_Title()
                                      );
                            break;
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Live comment preview

Post by onli »

Think the new version of livecomment created in the performance-related thread should find it's way to Spartacus.
sincerely
Attachments
serendipity_event_livecomment-2.5.3.tar.gz
(34.01 KiB) Downloaded 271 times
Post Reply