Wiking branch, master, updated. 9b138ed33561f7205e76ec7ac6287e119de46df5

Tomas Cerha cerha at devel.brailcom.org
Tue Jun 14 19:21:33 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Wiking".

The branch, master has been updated
       via  9b138ed33561f7205e76ec7ac6287e119de46df5 (commit)
       via  989d7c9f73ce0c00436fd6be7c005a7a9792667a (commit)
      from  fed08a4cdb85190d8d1edac5ba1d3fcf0bb81445 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9b138ed33561f7205e76ec7ac6287e119de46df5
Author: Tomas Cerha <cerha at brailcom.org>
Date:   Tue Jun 14 19:17:20 2011 +0200

    Fix insertion into CMS discussions

commit 989d7c9f73ce0c00436fd6be7c005a7a9792667a
Author: Tomas Cerha <cerha at brailcom.org>
Date:   Tue Jun 14 19:15:45 2011 +0200

    Use text_format instead of StructuredText data type

-----------------------------------------------------------------------

Summary of changes:
 lib/wiking/cms/cms.py     |   42 ++++++++++++++++++++----------------------
 lib/wiking/db.py          |   39 ++++++++++++++++++++++-----------------
 resources/css/default.css |    3 ---
 3 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/lib/wiking/cms/cms.py b/lib/wiking/cms/cms.py
index 2a2caee..70b51d1 100644
--- a/lib/wiking/cms/cms.py
+++ b/lib/wiking/cms/cms.py
@@ -746,9 +746,9 @@ class Panels(ContentManagementModule, Publishable):
                   descr=_("Number of items from the selected module, which "
                           "will be shown by the panel.")),
             # Translators: Content of a page (text or something else)
-            Field('content', _("Content"), height=10, width=80,
-                  descr=_("Additional text content displayed on the panel.")+\
-                  ' '+_STRUCTURED_TEXT_DESCR),
+            Field('content', _("Content"), height=10, width=80, text_format=pp.TextFormat.LCG,
+                  descr=(_("Additional text content displayed on the panel.") + ' ' +
+                         _STRUCTURED_TEXT_DESCR)),
             # Translators: Yes/no configuration of whether the page is
             # published. Followed by a checkbox.
             Field('published', _("Published"), default=True,
@@ -986,8 +986,12 @@ class Pages(ContentManagementModule):
             Field('description', _("Description"), width=64,
                   descr=_("Brief page description (shown as a tooltip and in site map).")),
             Field('_content', _("Content"), compact=True, height=20, width=80,
-                  descr=_STRUCTURED_TEXT_DESCR), #type=pd.StructuredText()),
-            Field('content'),
+                  # We need to be able to force max height of the field in
+                  #ShowForm to be able to show it formatted (plain text fields
+                  #get scrolled automatically, but structured text fields not).
+                  #text_format=pp.TextFormat.LCG,
+                  descr=_STRUCTURED_TEXT_DESCR),
+            Field('content', text_format=pp.TextFormat.LCG, descr=_STRUCTURED_TEXT_DESCR),
             # Translators: "Module" is an independent reusable part of a computer program (here a
             # module of Wiking CMS).
             Field('modname', _("Module"), display=_modtitle, prefer_display=True, not_null=False,
@@ -1776,18 +1780,15 @@ class News(ContentManagementModule, EmbeddableCMSModule):
                   descr=_("Date of the news item creation.")),
             Field('title', _("Title"), column_label=_("Message"), width=32,
                   descr=_("The item brief summary.")),
-            Field('content', _("Message"), height=6, width=80, type=pd.StructuredText,
-                  descr=_STRUCTURED_TEXT_DESCR + ' ' + \
-                  _("It is, however, recommened to use the simplest possible formatting, since "
-                    "the item may be also published through an RSS channel, which does not "
-                    "support formatting.")),
+            Field('content', _("Message"), height=6, width=80, text_format=pp.TextFormat.LCG,
+                  descr=_STRUCTURED_TEXT_DESCR),
             Field('author', _("Author"), codebook='Users'),
             Field('date_title', virtual=True,
                   computer=Computer(self._date_title, depends=('date', 'title'))))
         sorting = (('timestamp', DESC),)
         columns = ('title', 'timestamp', 'author')
         layout = ('timestamp', 'title', 'content')
-        list_layout = pp.ListLayout('title', meta=('timestamp', 'author'),  content='content',
+        list_layout = pp.ListLayout('title', meta=('timestamp', 'author'),  content=('content',),
                                     anchor="item-%s")
         def _date(self, record):
             return record['timestamp'].export(show_time=False)
@@ -1887,14 +1888,11 @@ class Discussions(News):
         help = _("Allow logged in users to post messages as in a simple forum.")
         table = 'news'
         def fields(self):
-            fields = pp.Fields([f for f in super(Discussions.Spec, self).fields() 
-                                if f.id() not in ('date', 'date_title')])
             # Translators: Field label for posting a message to the discussion.
-            overridden = (Field(inherit=fields['content'], label=_("Your comment"),
-                                compact=True, descr=_STRUCTURED_TEXT_DESCR),)
-            return tuple(fields.fields(override=overridden))
-            
-            return fields
+            override = (Field('content', label=_("Your comment"), compact=True,
+                              text_format=pp.TextFormat.PLAIN),)
+            return self._inherited_fields(Discussions.Spec, override=override,
+                                          exclude=('date', 'date_title'))
         sorting = (('timestamp', ASC),)
         columns = ('timestamp', 'author')
         layout = ('content',)
@@ -1929,7 +1927,7 @@ class Discussions(News):
             new_record = self._record(req, None, new=True, prefill=prefill)
             try:
                 transaction = self._transaction()
-                self._in_transaction(transaction, self._insert, req, record, transaction)
+                self._in_transaction(transaction, self._insert, req, new_record, transaction)
             except pd.DBException as e:
                 req.message(self._error_message(*self._analyze_exception(e)), type=req.ERROR)
             else:
@@ -2105,7 +2103,7 @@ class CommonTexts(SettingsManagementModule):
             Field('descr', _("Purpose"), type=pytis.data.String(), width=64, virtual=True,
                   computer=computer(self._description)),
             Field('content', _("Text"), width=80, height=10,
-                  descr=_("Edit the given text as needed, in accordance with structured text rules.")),
+                  text_format=pp.TextFormat.LCG, descr=_STRUCTURED_TEXT_DESCR),
             )
 
         columns = ('label', 'descr',)
@@ -2329,7 +2327,7 @@ class Emails(CommonTexts):
             Field('descr', _("Purpose"), width=64,
                   virtual=True, computer=computer(self._description)),
             Field('content', _("Text"), width=80, height=10,
-                  descr=_("Edit the given text as needed, in accordance with structured text rules.")),
+                  text_format=pp.TextFormat.LCG, descr=_STRUCTURED_TEXT_DESCR),
             Field('subject', _("Subject")),
             Field('cc', _("Additional recipients"),
                   descr=_("Comma separated list of e-mail addresses.")),
@@ -2509,7 +2507,7 @@ class EmailSpool(MailManagementModule):
                   codebook='UserGroups', null_display=_("All users")),
             Field('subject', _("Subject")),
             Field('content', _("Text"), width=80, height=10,
-                  descr=_("Edit the given text as needed, in accordance with structured text rules.")),
+                  text_format=pp.TextFormat.LCG, descr=_STRUCTURED_TEXT_DESCR),
             Field('date', _("Date"), type=DateTime(), default=now, editable=NEVER),
             Field('pid', editable=NEVER),
             Field('finished', editable=NEVER),
diff --git a/lib/wiking/db.py b/lib/wiking/db.py
index 2d3e069..37ac5ba 100644
--- a/lib/wiking/db.py
+++ b/lib/wiking/db.py
@@ -1914,22 +1914,20 @@ class RssModule(object):
         return self._record_uri(req, record, setlang=lang)
 
     def _rss_description(self, req, record):
-        def format(text):
-            parser = lcg.Parser()
-            content = lcg.Container(parser.parse(text))
-            node = lcg.ContentNode('', content=content)
-            exporter = lcg.HtmlExporter()
-            context = exporter.context(node, None)
-            return node.content().export(context)
-        if self._RSS_DESCR_COLUMN:
-            value = record[self._RSS_DESCR_COLUMN]
-            result = value.export()
-            if isinstance(value.type(), pytis.data.StructuredText):
-                result = format(result)
-            return result
-        else:
-            return None
+        return None
         
+    def _rss_structured_text_description(self, req, record):
+        text = self._rss_column_description(req, record)
+        parser = lcg.Parser()
+        content = lcg.Container(parser.parse(text))
+        node = lcg.ContentNode('', content=content)
+        exporter = lcg.HtmlExporter()
+        context = exporter.context(node, None)
+        return node.content().export(context)
+        
+    def _rss_column_description(self, req, record):
+        return record[self._RSS_DESCR_COLUMN].export()
+
     def _rss_date(self, req, record):
         if self._RSS_DATE_COLUMN:
             return record[self._RSS_DATE_COLUMN].value()
@@ -1952,6 +1950,13 @@ class RssModule(object):
         import wiking
         if not self._RSS_TITLE_COLUMN:
             raise NotFound
+        descr_column = self._RSS_DESCR_COLUMN
+        if descr_column is None:
+            get_description = self._rss_description
+        elif self._view.field(descr_column).text_format() == pp.TextFormat.LCG:
+            get_description = self._rss_structured_text_description
+        else:
+            get_description = self._rss_column_description
         lang = req.prefered_language()
         if relation:
             condition = self._binding_condition(*relation)
@@ -1975,7 +1980,7 @@ class RssModule(object):
             uri = self._rss_uri(req, record, lang=lang)
             if uri:
                 uri = base_uri + uri
-            description = self._rss_description(req, record)
+            description = get_description(req, record)
             if description:
                 description = translate(description)
             date = self._rss_date(req, record)
@@ -2077,7 +2082,7 @@ class PytisRssModule(PytisModule):
             elif raw:
                 return lambda record: translate(record[spec].value())
             # TODO: allow HTML formatting as in the old RssModule (hopefully more efficient).
-            #elif isinstance(self._type[spec], pytis.data.StructuredText()):
+            #elif ...:
             #    return lambda record: format(translate(record[spec].export()))
             else:
                 return lambda record: translate(record[spec].export())
diff --git a/resources/css/default.css b/resources/css/default.css
index b269b9d..73d0f1d 100644
--- a/resources/css/default.css
+++ b/resources/css/default.css
@@ -87,9 +87,6 @@ form.browse-form table td, form.browse-form table th {
 form.browse-form table td .tree-node {
     white-space: nowrap;
 }
-form.browse-form table td .multiline {
-    white-space: pre;
-}
 
 form.browse-form table tr { background-color: $color.table-cell; }
 form.browse-form table tr.even { background-color: $color.table-cell2; }


hooks/post-receive
-- 
Wiking



More information about the Wiking-cvs mailing list