Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the ability to assign background colors to the timeline entries for events. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | experimental |
| Files: | files | file ages | folders |
| SHA1: |
a5110365a3b4829899e3a82b7e24cf01 |
| User & Date: | drh 2010-10-02 03:28:48.000 |
Context
|
2010-10-02
| ||
| 12:37 | Event background colors are now working. check-in: 6f93ca9418 user: drh tags: experimental | |
| 03:28 | Add the ability to assign background colors to the timeline entries for events. check-in: a5110365a3 user: drh tags: experimental | |
| 00:25 | First working code for displaying and editing events. check-in: 419903ebd7 user: drh tags: experimental | |
Changes
Changes to src/event.c.
| ︙ | ︙ | |||
102 103 104 105 106 107 108 |
Blob event;
const char *zEventId;
char *zHtmlPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
char *zETime = (char*)P("t");
| | > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
Blob event;
const char *zEventId;
char *zHtmlPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
char *zETime = (char*)P("t");
const char *zComment = P("c");
const char *zClr;
if( zBody ){
zBody = mprintf("%s", zBody);
}
login_check_credentials();
zEventId = P("name");
if( zEventId==0 ){
|
| ︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
/* Need both check-in and wiki-write or wiki-create privileges in order
** to edit/create an event.
*/
if( !g.okWrite || (rid && !g.okWrWiki) || (!rid && !g.okNewWiki) ){
login_needed();
return;
}
/* If editing an existing event, extract the key fields to use as
** a starting point for the edit.
*/
if( rid && (zBody==0 || zETime==0 || zComment==0) ){
Manifest m;
Blob content;
| > > > > > > > > > > | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
/* Need both check-in and wiki-write or wiki-create privileges in order
** to edit/create an event.
*/
if( !g.okWrite || (rid && !g.okWrWiki) || (!rid && !g.okNewWiki) ){
login_needed();
return;
}
/* Figure out the color */
if( rid ){
zClr = db_text("", "SELECT bgcolor FROM event WHERE objid=%d", rid);
}else{
zClr = "";
}
zClr = PD("clr",zClr);
if( strcmp(zClr,"##")==0 ) zClr = PD("cclr","");
/* If editing an existing event, extract the key fields to use as
** a starting point for the edit.
*/
if( rid && (zBody==0 || zETime==0 || zComment==0) ){
Manifest m;
Blob content;
|
| ︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
blob_appendf(&event, "E %s %s\n", zETime, zEventId);
zETime[10] = ' ';
if( rid ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_appendf(&event, "P %s\n", zUuid);
free(zUuid);
}
if( g.zLogin ){
blob_appendf(&event, "U %F\n", g.zLogin);
}
blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&event, &cksum);
blob_appendf(&event, "Z %b\n", &cksum);
blob_reset(&cksum);
| > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
blob_appendf(&event, "E %s %s\n", zETime, zEventId);
zETime[10] = ' ';
if( rid ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_appendf(&event, "P %s\n", zUuid);
free(zUuid);
}
if( zClr && zClr[0] ){
blob_appendf(&event, "T +bgcolor * %F\n", zClr);
}
if( g.zLogin ){
blob_appendf(&event, "U %F\n", g.zLogin);
}
blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&event, &cksum);
blob_appendf(&event, "Z %b\n", &cksum);
blob_reset(&cksum);
|
| ︙ | ︙ | |||
198 199 200 201 202 203 204 |
}
if( zBody==0 ){
zBody = mprintf("<i>Event Text</i>");
}
zHtmlPageName = mprintf("Edit Event %S", zEventId);
style_header(zHtmlPageName);
if( P("preview")!=0 ){
| > > > > > > > > > | > > > > > | > > | > | > | > | > > | > | > > | > | > > > > | > > | > > > | | > | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
}
if( zBody==0 ){
zBody = mprintf("<i>Event Text</i>");
}
zHtmlPageName = mprintf("Edit Event %S", zEventId);
style_header(zHtmlPageName);
if( P("preview")!=0 ){
Blob title, tail, com;
@ <p><b>Timeline comment preview:</b></p>
@ <blockquote>
@ <table border="0">
if( zClr && zClr[0] ){
@ <tr><td style="background-color: %h(zClr);">
}else{
@ <tr><td>
}
blob_init(&com, zComment, -1);
wiki_convert(&com, 0, WIKI_INLINE);
@ </td></tr></table>
@ </blockquote>
@ <p><b>Page content preview:</b><p>
@ <blockquote>
blob_init(&event, zBody, -1);
if( wiki_find_title(&event, &title, &tail) ){
@ <h2 align="center">%h(blob_str(&title))</h2>
wiki_convert(&tail, 0, 0);
}else{
wiki_convert(&event, 0, 0);
}
@ </blockquote><hr />
blob_reset(&event);
}
for(n=2, z=zBody; z[0]; z++){
if( z[0]=='\n' ) n++;
}
if( n<20 ) n = 20;
if( n>40 ) n = 40;
@ <form method="post" action="%s(g.zBaseURL)/eventedit"><div>
login_insert_csrf_secret();
@ <input type="hidden" name="name" value="%h(zEventId)" />
@ <table border="0" cellspacing="10">
@ <tr><td align="right" valign="top"><b>Event Time:</b></td>
@ <td valign="top">
@ <input type="text" name="t" size="25" value="%h(zETime)" /></p>
@ </td></tr>
@ <tr><td align="right" valign="top"><b>Timeline Comment:</b></td>
@ <td valign="top">
@ <textarea name="c" class="eventedit" cols="80"
@ rows="3" wrap="virtual">%h(zComment)</textarea>
@ </td></tr>
@ <tr><td align="right" valign="top"><b>Background Color:</b></td>
@ <td valign="top">
render_color_chooser(0, zClr, 0, "clr", "cclr");
@ </td></tr>
@ <tr><td align="right" valign="top"><b>Page Content:</b></td>
@ <td valign="top">
@ <textarea name="w" class="eventedit" cols="80"
@ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
@ </td></tr>
@ <tr><td colspan="2">
@ <input type="submit" name="preview" value="Preview Your Changes" />
@ <input type="submit" name="submit" value="Apply These Changes" />
@ <input type="submit" name="cancel" value="Cancel" />
@ </td></tr></table>
@ </div></form>
style_footer();
}
|
Changes to src/info.c.
| ︙ | ︙ | |||
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 |
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
ci_page();
}else
{
artifact_page();
}
}
/*
** WEBPAGE: ci_edit
** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
**
** Present a dialog for updating properties of a baseline:
**
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 |
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
ci_page();
}else
{
artifact_page();
}
}
/*
** Generate HTML that will present the user with a selection of
** potential background colors for timeline entries.
*/
void render_color_chooser(
int fPropagate, /* Default value for propagation */
const char *zDefaultColor, /* The current default color */
const char *zIdPropagate, /* ID of form element checkbox. NULL for none */
const char *zId, /* The ID of the form element */
const char *zIdCustom /* ID of text box for custom color */
){
static const struct SampleColors {
const char *zCName;
const char *zColor;
} aColor[] = {
{ "(none)", "" },
{ "#f2dcdc", "#f2dcdc" },
{ "#f0ffc0", "#f0ffc0" },
{ "#bde5d6", "#bde5d6" },
{ "#c0ffc0", "#c0ffc0" },
{ "#c0fff0", "#c0fff0" },
{ "#c0f0ff", "#c0f0ff" },
{ "#d0c0ff", "#d0c0ff" },
{ "#ffc0ff", "#ffc0ff" },
{ "#ffc0d0", "#ffc0d0" },
{ "#fff0c0", "#fff0c0" },
{ "#c0c0c0", "#c0c0c0" },
{ "custom", "##" },
};
int nColor = sizeof(aColor)/sizeof(aColor[0])-1;
int stdClrFound = 0;
int i;
@ <table border="0" cellpadding="0" cellspacing="1">
if( zIdPropagate ){
@ <tr><td colspan="6" align="left">
if( fPropagate ){
@ <input type="checkbox" name="%s(zIdPropagate)" checked="checked" />
}else{
@ <input type="checkbox" name="%s(zIdPropagate)" />
}
@ Propagate color to descendants</td></tr>
}
@ <tr>
for(i=0; i<nColor; i++){
if( aColor[i].zColor[0] ){
@ <td style="background-color: %h(aColor[i].zColor);">
}else{
@ <td>
}
if( strcmp(zDefaultColor, aColor[i].zColor)==0 ){
@ <input type="radio" name="%s(zId)" value="%h(aColor[i].zColor)"
@ checked="checked" />
stdClrFound=1;
}else{
@ <input type="radio" name="%s(zId)" value="%h(aColor[i].zColor)" />
}
@ %h(aColor[i].zCName)</td>
if( (i%6)==5 && i+1<nColor ){
@ </tr><tr>
}
}
@ </tr><tr>
if (stdClrFound){
@ <td colspan="6">
@ <input type="radio" name="%s(zId)" value="%h(aColor[nColor].zColor)" />
}else{
@ <td style="background-color: %h(zDefaultColor);" colspan="6">
@ <input type="radio" name="%s(zId)" value="%h(aColor[nColor].zColor)"
@ checked="checked" />
}
@ %h(aColor[i].zCName)
@ <input type="text" name="%s(zIdCustom)"
@ id="%s(zIdCustom)" class="checkinUserColor"
@ value="%h(stdClrFound?"":zDefaultColor)" />
@ </td>
@ </tr>
@ </table>
}
/*
** WEBPAGE: ci_edit
** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
**
** Present a dialog for updating properties of a baseline:
**
|
| ︙ | ︙ | |||
1288 1289 1290 1291 1292 1293 1294 | const char *zNewBrFlag; const char *zNewBranch; const char *zCloseFlag; int fPropagateColor; char *zUuid; Blob comment; Stmt q; | < < < < < < < < < < < < < < < < < < < < < | 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 |
const char *zNewBrFlag;
const char *zNewBranch;
const char *zCloseFlag;
int fPropagateColor;
char *zUuid;
Blob comment;
Stmt q;
login_check_credentials();
if( !g.okWrite ){ login_needed(); return; }
rid = name_to_rid(P("r"));
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
" FROM event WHERE objid=%d", rid);
|
| ︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 |
zDate = db_text(0, "SELECT datetime(mtime)"
" FROM event WHERE objid=%d", rid);
if( zDate==0 ) fossil_redirect_home();
zNewDate = PD("dt",zDate);
zColor = db_text("", "SELECT bgcolor"
" FROM event WHERE objid=%d", rid);
zNewColor = PD("clr",zColor);
| | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
zDate = db_text(0, "SELECT datetime(mtime)"
" FROM event WHERE objid=%d", rid);
if( zDate==0 ) fossil_redirect_home();
zNewDate = PD("dt",zDate);
zColor = db_text("", "SELECT bgcolor"
" FROM event WHERE objid=%d", rid);
zNewColor = PD("clr",zColor);
if( strcmp(zNewColor,"##")==0 ){
zNewColor = P("clrcust");
}
fPropagateColor = P("pclr")!=0;
zNewTagFlag = P("newtag") ? " checked" : "";
zNewTag = PD("tagname","");
zNewBrFlag = P("newbr") ? " checked" : "";
zNewBranch = PD("brname","");
|
| ︙ | ︙ | |||
1499 1500 1501 1502 1503 1504 1505 | @ <tr><td align="right" valign="top"><b>Check-in Time:</b></td> @ <td valign="top"> @ <input type="text" name="dt" size="20" value="%h(zNewDate)" /> @ </td></tr> @ <tr><td align="right" valign="top"><b>Background Color:</b></td> @ <td valign="top"> | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 | @ <tr><td align="right" valign="top"><b>Check-in Time:</b></td> @ <td valign="top"> @ <input type="text" name="dt" size="20" value="%h(zNewDate)" /> @ </td></tr> @ <tr><td align="right" valign="top"><b>Background Color:</b></td> @ <td valign="top"> render_color_chooser(fPropagateColor, zNewColor, "pclr", "clr", "clrcust"); @ </td></tr> @ <tr><td align="right" valign="top"><b>Tags:</b></td> @ <td valign="top"> @ <input type="checkbox" name="newtag"%s(zNewTagFlag) /> @ Add the following new tag name to this check-in: @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)" /> |
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
627 628 629 630 631 632 633 |
if( p->zUser==0 ) goto manifest_syntax_error;
if( p->zAttachName ) goto manifest_syntax_error;
if( !seenZ ) goto manifest_syntax_error;
p->type = CFTYPE_TICKET;
}else if( p->zEventId ){
if( p->rDate<=0.0 ) goto manifest_syntax_error;
if( p->nCChild>0 ) goto manifest_syntax_error;
| < > > > > | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
if( p->zUser==0 ) goto manifest_syntax_error;
if( p->zAttachName ) goto manifest_syntax_error;
if( !seenZ ) goto manifest_syntax_error;
p->type = CFTYPE_TICKET;
}else if( p->zEventId ){
if( p->rDate<=0.0 ) goto manifest_syntax_error;
if( p->nCChild>0 ) goto manifest_syntax_error;
if( p->zTicketUuid!=0 ) goto manifest_syntax_error;
if( p->zWikiTitle!=0 ) goto manifest_syntax_error;
if( p->zWiki==0 ) goto manifest_syntax_error;
if( p->zAttachName ) goto manifest_syntax_error;
for(i=0; i<p->nTag; i++){
if( p->aTag[i].zName[0]!='+' ) goto manifest_syntax_error;
if( p->aTag[i].zUuid!=0 ) goto manifest_syntax_error;
}
if( !seenZ ) goto manifest_syntax_error;
p->type = CFTYPE_EVENT;
}else if( p->zWiki!=0 ){
if( p->rDate<=0.0 ) goto manifest_syntax_error;
if( p->nCChild>0 ) goto manifest_syntax_error;
if( p->nTag>0 ) goto manifest_syntax_error;
if( p->zTicketUuid!=0 ) goto manifest_syntax_error;
|
| ︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 |
int mid;
mid = uuid_to_rid(m.azCChild[i], 1);
if( mid>0 ){
db_multi_exec("DELETE FROM unclustered WHERE rid=%d", mid);
}
}
}
| | > > > | 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
int mid;
mid = uuid_to_rid(m.azCChild[i], 1);
if( mid>0 ){
db_multi_exec("DELETE FROM unclustered WHERE rid=%d", mid);
}
}
}
if( m.type==CFTYPE_CONTROL
|| m.type==CFTYPE_MANIFEST
|| m.type==CFTYPE_EVENT
){
for(i=0; i<m.nTag; i++){
int tid;
int type;
if( m.aTag[i].zUuid ){
tid = uuid_to_rid(m.aTag[i].zUuid, 1);
}else{
tid = rid;
|
| ︙ | ︙ |
Changes to www/fileformat.wiki.
| ︙ | ︙ | |||
421 422 423 424 425 426 427 428 429 430 431 432 433 434 | The following cards are allowed on an event artifact: <blockquote> <b>C</b> <i>comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br /> <b>E</b> <i>event-time</i> <i>event-id</i><br /> <b>P</b> <i>parent-artifact-id</i>+<br /> <b>U</b> <i>user-name</i><br /> <b>W</b> <i>size</i> <b>\n</b> <i>text</i> <b>\n</b><br /> <b>Z</b> <i>checksum</i> </blockquote> The C card contains text that is displayed on the timeline for the event. Exactly one C card is required on an event artifact. | > | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | The following cards are allowed on an event artifact: <blockquote> <b>C</b> <i>comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br /> <b>E</b> <i>event-time</i> <i>event-id</i><br /> <b>P</b> <i>parent-artifact-id</i>+<br /> <b>T</b> <b>+</b><i>tag-name</i> <b>*</b> <i>value</i><br /> <b>U</b> <i>user-name</i><br /> <b>W</b> <i>size</i> <b>\n</b> <i>text</i> <b>\n</b><br /> <b>Z</b> <i>checksum</i> </blockquote> The C card contains text that is displayed on the timeline for the event. Exactly one C card is required on an event artifact. |
| ︙ | ︙ | |||
444 445 446 447 448 449 450 | 40-character lower-case hexadecimal string. The option P card specifies a prior event with the same event-id from which the current event is an edit. The P card is a hint to the system that it might be space efficient to store one event as a delta of the other. | > > > > > > > > > > > > > > | > | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | 40-character lower-case hexadecimal string. The option P card specifies a prior event with the same event-id from which the current event is an edit. The P card is a hint to the system that it might be space efficient to store one event as a delta of the other. An event might contain one or more T-cards used to set [./branching.wiki#tags | tags or properties] on the event. The format of the T-card is the same as described in <i>Control Artifacts</i> section above, except that the second argument is the single characcter "<b>*</b>" instead of an artifact ID and the name is always prefaced by "<b>+</b>". The <b>*</b> in place of the artifact ID indicates that the tag or property applies to the current artifact. It is not possible to encode the current artifact ID as part of an artifact, since the act of inserting the artifact ID would change the artifact ID, hence a <b>*</b> is used to represent "self". The "<b>+</b>" on the name means that tags can only be add and they can only be non-propagating tags. A an event, T cards are normally used to set the background display color for timelines. The optional U card gives name of the user who entered the event. A single W card provides wiki text for the document associated with the event. The format of the W card is exactly the same as for a wiki artifact. The Z card is the usual checksum over the rest of the attachment artifact. |
| ︙ | ︙ | |||
590 591 592 593 594 595 596 | <td><b>T</b> (<b>+</b>|<b>*</b>|<b>-</b>)<i>tagname uuid value</i></td> <td align=center><b>X</b></td> <td align=center> </td> <td align=center><b>X</b></td> <td align=center> </td> <td align=center> </td> <td align=center> </td> | | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | <td><b>T</b> (<b>+</b>|<b>*</b>|<b>-</b>)<i>tagname uuid value</i></td> <td align=center><b>X</b></td> <td align=center> </td> <td align=center><b>X</b></td> <td align=center> </td> <td align=center> </td> <td align=center> </td> <td align=center><b>X</b></td> </tr> <tr> <td><b>U</b> <i>username</i></td> <td align=center><b>X</b></td> <td align=center> </td> <td align=center><b>X</b></td> <td align=center><b>X</b></td> |
| ︙ | ︙ |