Fossil SCM
Make it easier to use Events as quick notes: Display the title just above the text on Event pages. If there's no title in the wiki text, use the comment as a title.
Commit
27a4518e13c41e6016757469dcae30d7baa54225
Parent
8d703ff956578cb…
1 file changed
+13
-5
+13
-5
| --- src/event.c | ||
| +++ src/event.c | ||
| @@ -64,12 +64,14 @@ | ||
| 64 | 64 | char *zETime; /* Time of the event */ |
| 65 | 65 | char *zATime; /* Time the artifact was created */ |
| 66 | 66 | int specRid; /* rid specified by aid= parameter */ |
| 67 | 67 | int prevRid, nextRid; /* Previous or next edits of this event */ |
| 68 | 68 | Manifest *pEvent; /* Parsed event artifact */ |
| 69 | + Blob comment; /* Comment shown in timeline */ | |
| 69 | 70 | Blob fullbody; /* Complete content of the event body */ |
| 70 | 71 | Blob title; /* Title extracted from the event body */ |
| 72 | + int haveTitle; /* Whether a title was extracted */ | |
| 71 | 73 | Blob tail; /* Event body that comes after the title */ |
| 72 | 74 | Stmt q1; /* Query to search for the event */ |
| 73 | 75 | int showDetail; /* True to show details */ |
| 74 | 76 | |
| 75 | 77 | |
| @@ -116,12 +118,14 @@ | ||
| 116 | 118 | */ |
| 117 | 119 | pEvent = manifest_get(rid, CFTYPE_EVENT); |
| 118 | 120 | if( pEvent==0 ){ |
| 119 | 121 | fossil_panic("Object #%d is not an event", rid); |
| 120 | 122 | } |
| 123 | + blob_init(&comment, pEvent->zComment, -1); | |
| 121 | 124 | blob_init(&fullbody, pEvent->zWiki, -1); |
| 122 | - if( wiki_find_title(&fullbody, &title, &tail) ){ | |
| 125 | + haveTitle = wiki_find_title(&fullbody, &title, &tail); | |
| 126 | + if( haveTitle ){ | |
| 123 | 127 | style_header(blob_str(&title)); |
| 124 | 128 | }else{ |
| 125 | 129 | style_header("Event %S", zEventId); |
| 126 | 130 | tail = fullbody; |
| 127 | 131 | } |
| @@ -160,11 +164,10 @@ | ||
| 160 | 164 | } |
| 161 | 165 | |
| 162 | 166 | if( showDetail && g.okHistory ){ |
| 163 | 167 | int i; |
| 164 | 168 | const char *zClr = 0; |
| 165 | - Blob comment; | |
| 166 | 169 | |
| 167 | 170 | zATime = db_text(0, "SELECT datetime(%.17g)", pEvent->rDate); |
| 168 | 171 | @ <p>Event [<a href="%s(g.zTop)/artifact/%s(zUuid)">%S(zUuid)</a>] at |
| 169 | 172 | @ [<a href="%s(g.zTop)/timeline?c=%T(zETime)">%s(zETime)</a>] |
| 170 | 173 | @ entered by user <b>%h(pEvent->zUser)</b> on |
| @@ -179,17 +182,22 @@ | ||
| 179 | 182 | if( zClr ){ |
| 180 | 183 | @ <div style="background-color: %h(zClr);"> |
| 181 | 184 | }else{ |
| 182 | 185 | @ <div> |
| 183 | 186 | } |
| 184 | - blob_init(&comment, pEvent->zComment, -1); | |
| 185 | - wiki_convert(&comment, 0, WIKI_INLINE); | |
| 186 | - blob_reset(&comment); | |
| 187 | + if( haveTitle ){ | |
| 188 | + /* Don't display comment if it's used as the inline title below */ | |
| 189 | + wiki_convert(&comment, 0, WIKI_INLINE); | |
| 190 | + } | |
| 187 | 191 | @ </div> |
| 188 | 192 | @ </blockquote><hr /> |
| 189 | 193 | } |
| 190 | 194 | |
| 195 | + @ <h2> | |
| 196 | + wiki_convert(haveTitle ? &title : &comment, 0, WIKI_INLINE); | |
| 197 | + @ </h2> | |
| 198 | + | |
| 191 | 199 | wiki_convert(&tail, 0, 0); |
| 192 | 200 | style_footer(); |
| 193 | 201 | manifest_destroy(pEvent); |
| 194 | 202 | } |
| 195 | 203 | |
| 196 | 204 |
| --- src/event.c | |
| +++ src/event.c | |
| @@ -64,12 +64,14 @@ | |
| 64 | char *zETime; /* Time of the event */ |
| 65 | char *zATime; /* Time the artifact was created */ |
| 66 | int specRid; /* rid specified by aid= parameter */ |
| 67 | int prevRid, nextRid; /* Previous or next edits of this event */ |
| 68 | Manifest *pEvent; /* Parsed event artifact */ |
| 69 | Blob fullbody; /* Complete content of the event body */ |
| 70 | Blob title; /* Title extracted from the event body */ |
| 71 | Blob tail; /* Event body that comes after the title */ |
| 72 | Stmt q1; /* Query to search for the event */ |
| 73 | int showDetail; /* True to show details */ |
| 74 | |
| 75 | |
| @@ -116,12 +118,14 @@ | |
| 116 | */ |
| 117 | pEvent = manifest_get(rid, CFTYPE_EVENT); |
| 118 | if( pEvent==0 ){ |
| 119 | fossil_panic("Object #%d is not an event", rid); |
| 120 | } |
| 121 | blob_init(&fullbody, pEvent->zWiki, -1); |
| 122 | if( wiki_find_title(&fullbody, &title, &tail) ){ |
| 123 | style_header(blob_str(&title)); |
| 124 | }else{ |
| 125 | style_header("Event %S", zEventId); |
| 126 | tail = fullbody; |
| 127 | } |
| @@ -160,11 +164,10 @@ | |
| 160 | } |
| 161 | |
| 162 | if( showDetail && g.okHistory ){ |
| 163 | int i; |
| 164 | const char *zClr = 0; |
| 165 | Blob comment; |
| 166 | |
| 167 | zATime = db_text(0, "SELECT datetime(%.17g)", pEvent->rDate); |
| 168 | @ <p>Event [<a href="%s(g.zTop)/artifact/%s(zUuid)">%S(zUuid)</a>] at |
| 169 | @ [<a href="%s(g.zTop)/timeline?c=%T(zETime)">%s(zETime)</a>] |
| 170 | @ entered by user <b>%h(pEvent->zUser)</b> on |
| @@ -179,17 +182,22 @@ | |
| 179 | if( zClr ){ |
| 180 | @ <div style="background-color: %h(zClr);"> |
| 181 | }else{ |
| 182 | @ <div> |
| 183 | } |
| 184 | blob_init(&comment, pEvent->zComment, -1); |
| 185 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 186 | blob_reset(&comment); |
| 187 | @ </div> |
| 188 | @ </blockquote><hr /> |
| 189 | } |
| 190 | |
| 191 | wiki_convert(&tail, 0, 0); |
| 192 | style_footer(); |
| 193 | manifest_destroy(pEvent); |
| 194 | } |
| 195 | |
| 196 |
| --- src/event.c | |
| +++ src/event.c | |
| @@ -64,12 +64,14 @@ | |
| 64 | char *zETime; /* Time of the event */ |
| 65 | char *zATime; /* Time the artifact was created */ |
| 66 | int specRid; /* rid specified by aid= parameter */ |
| 67 | int prevRid, nextRid; /* Previous or next edits of this event */ |
| 68 | Manifest *pEvent; /* Parsed event artifact */ |
| 69 | Blob comment; /* Comment shown in timeline */ |
| 70 | Blob fullbody; /* Complete content of the event body */ |
| 71 | Blob title; /* Title extracted from the event body */ |
| 72 | int haveTitle; /* Whether a title was extracted */ |
| 73 | Blob tail; /* Event body that comes after the title */ |
| 74 | Stmt q1; /* Query to search for the event */ |
| 75 | int showDetail; /* True to show details */ |
| 76 | |
| 77 | |
| @@ -116,12 +118,14 @@ | |
| 118 | */ |
| 119 | pEvent = manifest_get(rid, CFTYPE_EVENT); |
| 120 | if( pEvent==0 ){ |
| 121 | fossil_panic("Object #%d is not an event", rid); |
| 122 | } |
| 123 | blob_init(&comment, pEvent->zComment, -1); |
| 124 | blob_init(&fullbody, pEvent->zWiki, -1); |
| 125 | haveTitle = wiki_find_title(&fullbody, &title, &tail); |
| 126 | if( haveTitle ){ |
| 127 | style_header(blob_str(&title)); |
| 128 | }else{ |
| 129 | style_header("Event %S", zEventId); |
| 130 | tail = fullbody; |
| 131 | } |
| @@ -160,11 +164,10 @@ | |
| 164 | } |
| 165 | |
| 166 | if( showDetail && g.okHistory ){ |
| 167 | int i; |
| 168 | const char *zClr = 0; |
| 169 | |
| 170 | zATime = db_text(0, "SELECT datetime(%.17g)", pEvent->rDate); |
| 171 | @ <p>Event [<a href="%s(g.zTop)/artifact/%s(zUuid)">%S(zUuid)</a>] at |
| 172 | @ [<a href="%s(g.zTop)/timeline?c=%T(zETime)">%s(zETime)</a>] |
| 173 | @ entered by user <b>%h(pEvent->zUser)</b> on |
| @@ -179,17 +182,22 @@ | |
| 182 | if( zClr ){ |
| 183 | @ <div style="background-color: %h(zClr);"> |
| 184 | }else{ |
| 185 | @ <div> |
| 186 | } |
| 187 | if( haveTitle ){ |
| 188 | /* Don't display comment if it's used as the inline title below */ |
| 189 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 190 | } |
| 191 | @ </div> |
| 192 | @ </blockquote><hr /> |
| 193 | } |
| 194 | |
| 195 | @ <h2> |
| 196 | wiki_convert(haveTitle ? &title : &comment, 0, WIKI_INLINE); |
| 197 | @ </h2> |
| 198 | |
| 199 | wiki_convert(&tail, 0, 0); |
| 200 | style_footer(); |
| 201 | manifest_destroy(pEvent); |
| 202 | } |
| 203 | |
| 204 |