List Info

Thread: expand_aliases-0.2 patch




expand_aliases-0.2 patch
user name
2007-05-08 16:30:48
hi samizdat-devel,

i agree that we should try the gnu bug + patch maintenance
services,
but since this is a low priority patch, i don't think it's
worth
posting to gnu - better start with the more serious ones. On
the other
hand, i did post it here earlier for pre-20070501 versions
and i checked
that it's easy (trivial) to update, so here it is anyway.

The name is bad, the routine contains data that should be
user (or at
least moderator) generated, and it's even
language-hardwired. :P.  Don't
use it!  Or if you do use it, remember that you'll have to
update it by
hand every time samizdat gets updated.

Dmitry's response was here, mainly about the
"description" feature:
http://lists.gnu.org/archive/html/samizdat
-devel/2007-01/msg00004.html

i'm not sure it's quite the same thing as
"description", since one or
many "descriptions" are included this way at
points in the content chosen
by the user. But i agree that they're related.

i've also updated:
  h
ttps://docs.indymedia.org/view/Devel/SamizdatHacks

and will add patch + bug reports to the gnu database
shortly...

cheers
boud


expand-aliases-0.2 - works on 0.6.0.20070506

---
/tmp/tmp_snapshot/samizdat/lib/samizdat/models/content.rb	20
07-04-26 02:11:26.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/models/content.rb	2007-05-08
20:15:26.389659320 +0200
 -10,6
+10,7 

  require 'samizdat/engine'
  require 'fileutils'
+require 'samizdat/helpers/expand_aliases.rb'

  begin
    require 'redcloth'
 -225,6
+226,7 
            } + "</p>n"
          }.join
        end
+    expand_aliases(html)  # WARNING: this is a temporary
hack
      Samizdat::Sanitize.new(config.xhtml).sanitize(html)
    end


--- /dev/null	2005-09-15 04:53:34.000000000 +0200
+++
/usr/lib/ruby/1.8/samizdat/helpers/expand_aliases.rb	2007-05
-08 20:23:36.084214432 +0200
 -0,0
+1,41 
+#!/usr/bin/env ruby
+#
+# Samizdat expand aliases
+#
+#   Copyright (c) 2002-2006  Dmitry Borodaenko
<angdraugdebian.org>,
+#   Boud (Indymedia) <boudriseup.net>
+#
+#   This program is free software.
+#   You can distribute/modify this program under the terms
of
+#   the GNU General Public License version 2 or later.
+#
+# vim: et sw=2 sts=2 ts=8 tw=0
+
+require 'samizdat/engine'
+
+# WARNING: This is a quick and dirty hack, including
hardwiring of
+# language and even a resource number. Use it only if you
need something
+# quick to handle an emergency. Avoid becoming dependent on
it.
+# Even the name is a bad name. You have been warned. If it
melts your
+# hard disk drive, don't complain. 
+
+def expand_aliases(content)
+  aliases ={
+    # Lamanie Zasady Redakcyjnych 
+    /{}/ =>
+      '<p style="background-color: yellow; color:
black; border: 2px dashed red;">' +
+      ' <b>Ten artykuł/komentarz jest podejrzany
być niezgodny z ' +
+      ' <a href="/2657">zasadami
redakcyjnymi</a>.</b></p>',
+    /{{ŁZR}}/ =>
+      '<p style="background-color: yellow; color:
black; border: 2px dashed red;">' +
+      ' <b>Ten artykuł/komentarz jest podejrzany
być niezgodny z ' +
+      ' <a href="/2657">zasadami
redakcyjnymi</a>.</b></p>',
+    /{}/ =>
+      '<i><a href="htt
p://pl.wikipedia.org/wiki/Textile">Ten
artykuł/komentarz jest ' + 
+      'napisany z skrótami
,,textile"</a></i>'
+  }
+ 
+  aliases.each {|alias_key, alias_value|
content.gsub!(alias_key, alias_value)}
+
+end
+


_______________________________________________
samizdat-devel mailing list
samizdat-develnongnu.org
http://lists.nongnu.org/mailman/listinfo/samizdat-devel

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )