From assaph at gmail.com Wed Dec 6 00:26:27 2006 From: assaph at gmail.com (Assaph Mehr) Date: Wed, 6 Dec 2006 16:26:27 +1100 Subject: [Pimki-users] [chunk[syntax highlight]] alpha version In-Reply-To: <418361960611250918t7ec2ad72yfcfe9f2d00702444@mail.gmail.com> References: <418361960611250918t7ec2ad72yfcfe9f2d00702444@mail.gmail.com> Message-ID: <3ff47be90612052126r72f1ce0fse04aff8ec941cf3b@mail.gmail.com> I'm a bad bad person who should be spanked. Sorry for the extreme delay in responding! Life is err... hectic. As for actual feedback, here are a few notes: 1. The regexp is greedy in matching the content, so it will match everything from the first starting tag to the last closing tag. The simple solution is to add a ? mark, like: SYNTAX_HIGHLIGHT_PATTERN = %r<\[code\[([\w]+)\]\](.*?)\[\[code\]\]>im 2. I haven't tested the rendering speed, but I wouldn't be too concerned about speed at this stage - it looks ok to me. I have implemented caching on the chunk so it only calls CodeRay once. The whole thing can be abbreviated to: --- CODE --- class SyntacticHighlightChunk < Chunk SYNTAX_HIGHLIGHT_PATTERN = %r<\[code\[([\w]+)\]\](.*?)\[\[code\]\]>im def self.pattern() SYNTAX_HIGHLIGHT_PATTERN end def code() params[1].strip end def language() params[0].strip.downcase.to_sym end def resolved_text(view) cache.to_s end def initialize(options) super set_cache CodeRay.encode(code, language, :div, :line_numbers => :table) end end --- END CODE --- Notes: * I changed the main processing to be in the #initialize method. * The result is not expected to change each time the page is displayed, so it's kept in the cache * CodeRay seems to silently ignore the language if it's an unknown one, so skipped the matching * Changed the :wrap to :div. A :wrap => :page results in a complete HTML page, embedded in the main Pimki page. This makes it only a div. This also means that it requires the CSS style definitions to be included so I added these lines to the layouts/default.rhtml template as part of the style section: <%= CodeRay::Styles[:cycnus]::CSS_MAIN_STYLES %> <%= CodeRay::Styles[:cycnus]::TOKEN_COLORS %> You can add some checks if the page has any SyntacticHighlightChunks, but I don't think this is really necessary. Unfortunately this had a bug, in that the
 inside the .CodeRay
div doesn't seem to be respected. Adding :line_numbers => :tables
seems to have fixed it.



I have attached a full diff for the affected files (with svn diff).
All it needs now before applying are some tests....

Thanks again for all your work!
Sorry that I didn't respond earlier - I very much appreciate your efforts.

Cheers,
Assaph

CodeRay seems to silently ignore the language if you give it an unknown
On 11/26/06, Nicolas Delsaux  wrote:
> So ...
> After just a few seconds for coding it :-)) I wrote a chunk for
> managing syntax highlight. This chunk is described in the diff joined.
>
> It requires coderay, so don't forget to gem install coderay
> Furthermore, i didn't diffed the revision.rb wherre this chunk is
> added as a pre-rendering one.
>
> Finally, here are the following issues :
> 1 - regexp may not handle more than one highlighted section (i must
> find out why)
> 2 - contrary to coderay's author description, i find coderay to be
> quite slow (I guess it's more du to my poor ruby, pimki and coderay
> knowledge, here is why coderay's author will receive a copy of this
> mail, with all my thanks for his library), requiring caching (which i
> was not able to install, due to a cache size issue - ah, the joices of
> DB-driven development), so it mlay slow down rendering ... a solution
> should be latter found.
>
> Besides, it's a good alpha version and a good entry point in pimki's
> marvelous world.
>
> --
> Nicolas Delsaux
> N'imprimez ce mail que si vous ne savez pas le lire sur l'?cran : les
> ?lectrons se recyclent bien, le papier, beaucoup moins bien.
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: syntax_highlight2.diff
Type: application/octet-stream
Size: 4109 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/pimki-users/attachments/20061206/16de7df1/attachment.obj 

From thomaslissajoux at gmail.com  Wed Dec 20 05:04:46 2006
From: thomaslissajoux at gmail.com (thomas lissajoux)
Date: Wed, 20 Dec 2006 11:04:46 +0100
Subject: [Pimki-users] password problem
Message-ID: <45890ABE.9020405@gmail.com>

I'm posting my own little story, in case it might help someone. I'm
encountering the 'lost password' problem. I've looked up and
tried to follow instructions from the following sources :
1. http://instiki.org/show/FAQ
    But for pimki, there is no such thing as a sqlite db, so it's not
    appropriate.
2. If trying to debug_storage, cf :
http://rubyforge.org/pipermail/instiki-users/2005-August/000215.html
http://svn.instiki.org/instiki/branches/instiki-madeleine/script/debug_storage

Here's what I obtain :
 > E:\Work\web\pimki\pimki_2_zombie>irb
 > irb(main):001:0> load 'script/debug_storage'
 > NoMethodError: undefined method `require_gem' for main:Object
 >         from ./script/debug_storage:54
 >         from (irb):1
a simple "require 'rubygems'" was needed before and I could then
poke through and get the password...

By the way, how can this 'require' be avoided ? some missing/incorrect
environment variable somewhere ?

Tom

From assaph at gmail.com  Wed Dec 20 05:26:16 2006
From: assaph at gmail.com (Assaph Mehr)
Date: Wed, 20 Dec 2006 21:26:16 +1100
Subject: [Pimki-users] password problem
In-Reply-To: <45890ABE.9020405@gmail.com>
References: <45890ABE.9020405@gmail.com>
Message-ID: <3ff47be90612200226r4ab10e74y8facf119ea2b6a0f@mail.gmail.com>

>     But for pimki, there is no such thing as a sqlite db, so it's not
>     appropriate.

Yep, working on it :)

> By the way, how can this 'require' be avoided ? some missing/incorrect
> environment variable somewhere ?

I normally set "RUBYOPT=-rubygems" to automatically load rubygems.
I'll add a "require 'rubygems'" to the debug_storage script. It's
there because of the reliance on an older version of Rails (1.0.0).
I'll clean it up later.

Cheers,
Assaph