Check-in [ebb2765954]
Not logged in
Overview

SHA1 Hash:ebb2765954407a3ebe5b252130f3f7d7f0230330
Date: 2007-12-04 02:47:49
User: drh
Comment:Add the timeline display preferences page with the ability to turn on and off block markup in timeline comments and to limit the length of timeline comments.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/setup.c from [ecaf658269] to [89b2ca9e01].

@@ -64,10 +64,12 @@
     "Grant privileges to individual users.");
   setup_menu_entry("Access", "setup_access",
     "Control access settings.");
   setup_menu_entry("Configuration", "setup_config",
     "Configure the WWW components of the repository");
+  setup_menu_entry("Timeline", "setup_timeline",
+    "Timeline display preferences");
   setup_menu_entry("Tickets", "setup_ticket",
     "Configure the trouble-ticketing system for this repository");
   setup_menu_entry("CSS", "setup_editcss",
     "Edit the Cascading Style Sheet used by all pages of this repository");
   setup_menu_entry("Header", "setup_header",
@@ -528,12 +530,40 @@
   @ <p>The number of hours for which a login is valid.  This must be a
   @ positive number.  The default is 8760 hours which is approximately equal
   @ to a year.</p>
 
   @ <hr>
-  onoff_attribute("Allow anonymous signup", "anon-signup", "asu", 0);
-  @ <p>Allow users to create their own accounts</p>
+  @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
+  @ </form>
+  db_end_transaction(0);
+  style_footer();
+}
+
+/*
+** WEBPAGE: setup_timeline
+*/
+void setup_timeline(void){
+  login_check_credentials();
+  if( !g.okSetup ){
+    login_needed();
+  }
+
+  style_header("Timeline Display Preferences");
+  db_begin_transaction();
+  @ <form action="%s(g.zBaseURL)/setup_timeline" method="POST">
+
+  @ <hr>
+  onoff_attribute("Block markup in timeline",
+                  "timeline-block-markup", "tbm", 0);
+  @ <p>In timeline displays, check-in comments can be displayed with or
+  @ without block markup (paragraphs, tables, etc.)</p>
+
+  @ <hr>
+  entry_attribute("Max timeline comment length", 6,
+                  "timeline-max-comment", "tmc", "0");
+  @ <p>The maximum length of a comment to be displayed in a timeline.
+  @ "0" there is no length limit.</p>
 
   @ <hr>
   @ <p><input type="submit"  name="submit" value="Apply Changes"></p>
   @ </form>
   db_end_transaction(0);

Modified src/timeline.c from [88675c9828] to [6f6c62303a].

@@ -96,13 +96,22 @@
   int *pLastEvent,
   int (*xCallback)(int, Blob*),
   Blob *pArg
  ){
   int cnt = 0;
+  int wikiFlags;
+  int mxWikiLen;
   Blob comment;
   char zPrevDate[20];
   zPrevDate[0] = 0;
+
+  mxWikiLen = db_get_int("timeline-max-comment", 0);
+  if( db_get_boolean("timeline-block-markup", 0) ){
+    wikiFlags = WIKI_INLINE;
+  }else{
+    wikiFlags = WIKI_INLINE | WIKI_NOBLOCK;
+  }
 
   db_multi_exec(
      "CREATE TEMP TABLE IF NOT EXISTS seen(rid INTEGER PRIMARY KEY);"
      "DELETE FROM seen;"
   );
@@ -157,19 +166,19 @@
       }
     }else{
       hyperlink_to_uuid(zUuid);
     }
     db_column_blob(pQuery, 3, &comment);
-    if( blob_size(&comment)>200 ){
+    if( mxWikiLen>0 && blob_size(&comment)>mxWikiLen ){
       Blob truncated;
       blob_zero(&truncated);
-      blob_append(&truncated, blob_buffer(&comment), 200);
+      blob_append(&truncated, blob_buffer(&comment), mxWikiLen);
       blob_append(&truncated, "...", 3);
-      wiki_convert(&truncated, 0, WIKI_INLINE);
+      wiki_convert(&truncated, 0, wikiFlags);
       blob_reset(&truncated);
     }else{
-      wiki_convert(&comment, 0, WIKI_INLINE);
+      wiki_convert(&comment, 0, wikiFlags);
     }
     blob_reset(&comment);
     @ (by %h(zUser))</td></tr>
   }
   @ </table>

Modified src/wikiformat.c from [d9ba82df4d] to [8bd2fe1f58].

@@ -32,10 +32,11 @@
 ** Allowed wiki transformation operations
 */
 #define WIKI_NOFOLLOW       0x001
 #define WIKI_HTML           0x002
 #define WIKI_INLINE         0x004  /* Do not surround with <p>..</p> */
+#define WIKI_NOBLOCK        0x008  /* No block markup of any kind */
 #endif
 
 
 /*
 ** These are the only markup attributes allowed.
@@ -195,10 +196,15 @@
 /*
 ** These markup types must have an end tag.
 */
 #define MUTYPE_STACK  (MUTYPE_BLOCK | MUTYPE_FONT | MUTYPE_LIST | MUTYPE_TABLE)
 
+/*
+** This markup types are allowed for "inline" text.
+*/
+#define MUTYPE_INLINE (MUTYPE_FONT | MUTYPE_HYPERLINK)
+
 static const struct AllowedMarkup {
   const char *zName;       /* Name of the markup */
   char iCode;              /* The MARKUP_* code */
   short int iType;         /* The MUTYPE_* code */
   int allowedAttr;         /* Allowed attributes on this markup */
@@ -304,15 +310,16 @@
 #define TOKEN_TEXT          9    /* None of the above */
 
 /*
 ** State flags
 */
-#define AT_NEWLINE        0x001  /* At start of a line */
-#define AT_PARAGRAPH      0x002  /* At start of a paragraph */
-#define ALLOW_WIKI        0x004  /* Allow wiki markup */
-#define FONT_MARKUP_ONLY  0x008  /* Only allow MUTYPE_FONT markup */
-#define IN_LIST           0x010  /* Within wiki <ul> or <ol> */
+#define AT_NEWLINE          0x001  /* At start of a line */
+#define AT_PARAGRAPH        0x002  /* At start of a paragraph */
+#define ALLOW_WIKI          0x004  /* Allow wiki markup */
+#define FONT_MARKUP_ONLY    0x008  /* Only allow MUTYPE_FONT markup */
+#define INLINE_MARKUP_ONLY  0x010  /* Allow only "inline" markup */
+#define IN_LIST             0x020  /* Within wiki <ul> or <ol> */
 
 /*
 ** Current state of the rendering engine
 */
 typedef struct Renderer Renderer;
@@ -834,67 +841,83 @@
 */
 static void wiki_render(Renderer *p, char *z){
   int tokenType;
   ParsedMarkup markup;
   int n;
+  int inlineOnly = (p->state & INLINE_MARKUP_ONLY)!=0;
 
   while( z[0] ){
     n = nextToken(z, p, &tokenType);
     p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
     switch( tokenType ){
       case TOKEN_PARAGRAPH: {
-        if( p->wikiList ){
-          popStackToTag(p, p->wikiList);
-          p->wikiList = 0;
-        }
-        endAutoParagraph(p);
-        blob_appendf(p->pOut, "\n\n", 1);
-        p->wantAutoParagraph = 1;
+        if( inlineOnly ){
+          /* blob_append(p->pOut, " &para; ", -1); */
+          blob_append(p->pOut, " &nbsp;&nbsp; ", -1);
+        }else{
+          if( p->wikiList ){
+            popStackToTag(p, p->wikiList);
+            p->wikiList = 0;
+          }
+          endAutoParagraph(p);
+          blob_appendf(p->pOut, "\n\n", 1);
+          p->wantAutoParagraph = 1;
+        }
         p->state |= AT_PARAGRAPH|AT_NEWLINE;
         break;
       }
       case TOKEN_NEWLINE: {
         blob_append(p->pOut, "\n", 1);
         p->state |= AT_NEWLINE;
         break;
       }
       case TOKEN_BULLET: {
-        if( p->wikiList!=MARKUP_UL ){
-          if( p->wikiList ){
-            popStackToTag(p, p->wikiList);
+        if( inlineOnly ){
+          blob_append(p->pOut, " &#149; ", -1);
+        }else{
+          if( p->wikiList!=MARKUP_UL ){
+            if( p->wikiList ){
+              popStackToTag(p, p->wikiList);
+            }
+            pushStack(p, MARKUP_UL);
+            blob_append(p->pOut, "<ul>", 4);
+            p->wikiList = MARKUP_UL;
           }
-          pushStack(p, MARKUP_UL);
-          blob_append(p->pOut, "<ul>", 4);
-          p->wikiList = MARKUP_UL;
-        }
-        popStackToTag(p, MARKUP_LI);
-        startAutoParagraph(p);
-        pushStack(p, MARKUP_LI);
-        blob_append(p->pOut, "<li>", 4);
+          popStackToTag(p, MARKUP_LI);
+          startAutoParagraph(p);
+          pushStack(p, MARKUP_LI);
+          blob_append(p->pOut, "<li>", 4);
+        }
         break;
       }
       case TOKEN_ENUM: {
-        if( p->wikiList!=MARKUP_OL ){
-          if( p->wikiList ){
-            popStackToTag(p, p->wikiList);
+        if( inlineOnly ){
+          blob_appendf(p->pOut, " (%d) ", atoi(z));
+        }else{
+          if( p->wikiList!=MARKUP_OL ){
+            if( p->wikiList ){
+              popStackToTag(p, p->wikiList);
+            }
+            pushStack(p, MARKUP_OL);
+            blob_append(p->pOut, "<ol>", 4);
+            p->wikiList = MARKUP_OL;
           }
-          pushStack(p, MARKUP_OL);
-          blob_append(p->pOut, "<ol>", 4);
-          p->wikiList = MARKUP_OL;
-        }
-        popStackToTag(p, MARKUP_LI);
-        startAutoParagraph(p);
-        pushStack(p, MARKUP_LI);
-        blob_appendf(p->pOut, "<li value=\"%d\">", atoi(z));
+          popStackToTag(p, MARKUP_LI);
+          startAutoParagraph(p);
+          pushStack(p, MARKUP_LI);
+          blob_appendf(p->pOut, "<li value=\"%d\">", atoi(z));
+        }
         break;
       }
       case TOKEN_INDENT: {
-        assert( p->wikiList==0 );
-        pushStack(p, MARKUP_BLOCKQUOTE);
-        blob_append(p->pOut, "<blockquote>", -1);
-        p->wantAutoParagraph = 0;
-        p->wikiList = MARKUP_BLOCKQUOTE;
+        if( inlineOnly ){
+          assert( p->wikiList==0 );
+          pushStack(p, MARKUP_BLOCKQUOTE);
+          blob_append(p->pOut, "<blockquote>", -1);
+          p->wantAutoParagraph = 0;
+          p->wikiList = MARKUP_BLOCKQUOTE;
+        }
         break;
       }
       case TOKEN_CHARACTER: {
         startAutoParagraph(p);
         if( z[0]=='<' ){
@@ -957,10 +980,12 @@
           startAutoParagraph(p);
           blob_append(p->pOut, "&lt;", 4);
           n = 1;
         }else if( (markup.iType&MUTYPE_FONT)==0
                     && (p->state & FONT_MARKUP_ONLY)!=0 ){
+          /* Do nothing */
+        }else if( inlineOnly && (markup.iType&MUTYPE_INLINE)==0 ){
           /* Do nothing */
         }else if( markup.iCode==MARKUP_NOWIKI ){
           if( markup.endTag ){
             p->state |= ALLOW_WIKI;
           }else{
@@ -1035,11 +1060,18 @@
   char *z;
   Renderer renderer;
 
   memset(&renderer, 0, sizeof(renderer));
   renderer.state = ALLOW_WIKI|AT_NEWLINE|AT_PARAGRAPH;
-  renderer.wantAutoParagraph = (flags & WIKI_INLINE)==0;
+  if( flags & WIKI_NOBLOCK ){
+    renderer.state |= INLINE_MARKUP_ONLY;
+  }
+  if( flags & WIKI_INLINE ){
+    renderer.wantAutoParagraph = 0;
+  }else{
+    renderer.wantAutoParagraph = 1;
+  }
   if( pOut ){
     renderer.pOut = pOut;
   }else{
     renderer.pOut = cgi_output_blob();
   }