samizdat-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (1) fr.po trivial; (2) automatic URLs for plain text format?


From: boud
Subject: Re: (1) fr.po trivial; (2) automatic URLs for plain text format?
Date: Thu, 30 Nov 2006 04:37:03 +0100 (CET)

hi all,

On Wed, 29 Nov 2006, Dmitry Borodaenko wrote:

On 11/29/06, boud <address@hidden> wrote:

(2) auto-URL patch
(...)
What do people think of something like the following patch for
"text/plain" articles?

The reason for it is that in typical indymedia cms's, wikis in
general and the mailman archiver, any sequence of characters such as
http://some.thing/what/ever   gets substituted with an a href link,
but it doesn't happen in samizdat-0.5.5.

Heh, I had it planned for a bit later:
http://cvs.savannah.gnu.org/viewcvs/samizdat/samizdat/TODO?rev=1.99

ummm.... Sorry, but i don't see it listed there.  Where is it?


One thing you certainly got wrong is the choice of format. Default
format for Samizdat messages is not text/plain, it's nil (no format
specified). text/plain is, as the comment says, verbatim plain text:
try to use it and see what I mean. I believe you intended your patch
for the default format.

Wow! i found a dramatic way to clarify what you're saying :).

emacs: M-x artist-mode

The difference is: * ascii art in text/plain mode looks beautiful
  e.g. http://belarus.indymedia.org/7842  (well, maybe not picasso ;)
* ascii art in default mode (<p> para </p>) looks terrible


So i agree that patch should only be done for the default format.  i
don't think people can complain about not having auto-URLs if they
choose to click on "plain/text" instead of just leaving the default
option.


But I think your argument is valid and it really can happen a bit
earlier, if I find a regexp that will do the job right. First thing to
do is look at URI module which has all the necessary regexps and is
already loaded by Samizdat.

You're right: /usr/lib/ruby/1.8/uri/ has the necessary stuff.

How does this look:  patch-autoURL-0.2 ?

Any chance of this getting into 0.6.0? ;)

And what time scale are you thinking of for 0.6.0? i might try a spanish translation, since that would particularly be useful for the
indymedia community...


BTW, i think that somewhere at the beginning of the uri_list.each loop
will in the future be a convenient place to call a future routine
which will trap people putting in wiki/blog link spam - but that will
also need to be used for the textile and html formats.

cheers
boud



--- s061116/samizdat/lib/samizdat/engine/template.rb    2006-11-16 
02:03:19.000000000 +0100
+++ /usr/lib/ruby/1.8/samizdat/engine/template.rb       2006-11-30 
04:19:27.560331168 +0100
@@ -412,9 +412,17 @@
           raise RuntimeError, $!.message
         end
       else   # default text rendering
-        CGI.escapeHTML(content).split(/^\s*$/).collect {|p|
+        html_escaped = CGI.escapeHTML(content).split(/^\s*$/).collect {|p|
           '<p>' + p + "</p>\n"
         }.join
+       uri_list = URI.extract(html_escaped)
+
+        # convert each URI to a (grouped) regexp and use \1 to replace it
+ uri_list.each do |uri| + re = Regexp.new('(' + Regexp.escape(uri) + ')') + html_escaped.gsub!(re, '<a href="\1">\1</a>') + end + html_escaped
       end
     Samizdat::Sanitize.new(config.xhtml).sanitize(html)
   end





reply via email to

[Prev in Thread] Current Thread [Next in Thread]