Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enhancements to "divider" processing in web timelines. Only show a single divider if two or more occur beside each other. Add the "nd" query parameter to suppress all dividers. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
c89200831173ed8dbfc255c347bae4c0 |
| User & Date: | drh 2011-01-14 17:16:34.397 |
Context
|
2011-01-14
| ||
| 20:54 | Remove some dead code from the web timeline. ... (check-in: cbc41ff4c9 user: drh tags: trunk) | |
| 17:16 | Enhancements to "divider" processing in web timelines. Only show a single divider if two or more occur beside each other. Add the "nd" query parameter to suppress all dividers. ... (check-in: c892008311 user: drh tags: trunk) | |
| 17:00 | Fix a cast on 64-bit windows. Ticket [6585b6c5d9058212ceb]. ... (check-in: 3c62ea139a user: drh tags: trunk) | |
Changes
Changes to src/timeline.c.
| ︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
int wikiFlags;
int mxWikiLen;
Blob comment;
int prevTagid = 0;
int suppressCnt = 0;
char zPrevDate[20];
GraphContext *pGraph = 0;
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;
| > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
int wikiFlags;
int mxWikiLen;
Blob comment;
int prevTagid = 0;
int suppressCnt = 0;
char zPrevDate[20];
GraphContext *pGraph = 0;
int prevWasDivider = 0; /* True if previous output row was <hr> */
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;
|
| ︙ | ︙ | |||
226 227 228 229 230 231 232 |
if( suppressCnt ){
@ <tr><td /><td /><td>
@ <span class="timelineDisabled">... %d(suppressCnt) similar
@ event%s(suppressCnt>1?"s":"") omitted.</span></td></tr>
suppressCnt = 0;
}
if( fossil_strcmp(zType,"div")==0 ){
| > | > > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
if( suppressCnt ){
@ <tr><td /><td /><td>
@ <span class="timelineDisabled">... %d(suppressCnt) similar
@ event%s(suppressCnt>1?"s":"") omitted.</span></td></tr>
suppressCnt = 0;
}
if( fossil_strcmp(zType,"div")==0 ){
if( !prevWasDivider ){
@ <tr><td colspan="3"><hr /></td></tr>
}
prevWasDivider = 1;
continue;
}
prevWasDivider = 0;
if( memcmp(zDate, zPrevDate, 10) ){
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
@ <tr><td>
@ <div class="divider">%s(zPrevDate)</div>
@ </td></tr>
}
memcpy(zTime, &zDate[11], 5);
|
| ︙ | ︙ | |||
653 654 655 656 657 658 659 |
url_render(pUrl, zParam, zValue, zRemove, 0));
}
/*
** zDate is a localtime date. Insert records into the
** "timeline" table to cause <hr> to be inserted before and after
| | > | > > > > > > > > > | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
url_render(pUrl, zParam, zValue, zRemove, 0));
}
/*
** zDate is a localtime date. Insert records into the
** "timeline" table to cause <hr> to be inserted before and after
** entries of that date. If zDate==NULL then put dividers around
** the event identified by rid.
*/
static void timeline_add_dividers(const char *zDate, int rid){
char *zToDel = 0;
if( zDate==0 ){
zToDel = db_text(0,"SELECT datetime(mtime,'localtime') FROM event"
" WHERE objid=%d", rid);
zDate = zToDel;
if( zDate==0 ) zDate = "1";
}
db_multi_exec(
"INSERT INTO timeline(rid,sortby,etype)"
"VALUES(-1,julianday(%Q,'utc')-5.0e-6,'div')",
zDate
);
db_multi_exec(
"INSERT INTO timeline(rid,sortby,etype)"
"VALUES(-2,julianday(%Q,'utc')+5.0e-6,'div')",
zDate
);
fossil_free(zToDel);
}
/*
** WEBPAGE: timeline
**
** Query parameters:
**
** a=TIMESTAMP after this date
** b=TIMESTAMP before this date.
** c=TIMESTAMP "circa" this date.
** n=COUNT number of events in output
** p=RID artifact RID and up to COUNT parents and ancestors
** d=RID artifact RID and up to COUNT descendants
** t=TAGID show only check-ins with the given tagid
** r=TAGID show check-ins related to tagid
** u=USER only if belonging to this user
** y=TYPE 'ci', 'w', 't', 'e'
** s=TEXT string search (comment and brief)
** ng Suppress the graph if present
** nd Suppress "divider" lines
** f=RID Show family (immediate parents and children) of RID
**
** p= and d= can appear individually or together. If either p= or d=
** appear, then u=, y=, a=, and b= are ignored.
**
** If a= and b= appear, only a= is used. If neither appear, the most
** recent events are choosen.
|
| ︙ | ︙ | |||
712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
const char *zType = PD("y","all"); /* Type of events. All if NULL */
const char *zAfter = P("a"); /* Events after this time */
const char *zBefore = P("b"); /* Events before this time */
const char *zCirca = P("c"); /* Events near this time */
const char *zTagName = P("t"); /* Show events with this tag */
const char *zBrName = P("r"); /* Show events related to this tag */
const char *zSearch = P("s"); /* Search string */
HQuery url; /* URL for various branch links */
int tagid; /* Tag ID */
int tmFlags; /* Timeline flags */
/* To view the timeline, must have permission to read project data.
*/
login_check_credentials();
| > | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
const char *zType = PD("y","all"); /* Type of events. All if NULL */
const char *zAfter = P("a"); /* Events after this time */
const char *zBefore = P("b"); /* Events before this time */
const char *zCirca = P("c"); /* Events near this time */
const char *zTagName = P("t"); /* Show events with this tag */
const char *zBrName = P("r"); /* Show events related to this tag */
const char *zSearch = P("s"); /* Search string */
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
HQuery url; /* URL for various branch links */
int tagid; /* Tag ID */
int tmFlags; /* Timeline flags */
/* To view the timeline, must have permission to read project data.
*/
login_check_credentials();
|
| ︙ | ︙ | |||
766 767 768 769 770 771 772 |
if( d_rid ){
compute_descendants(d_rid, nEntry+1);
nd = db_int(0, "SELECT count(*)-1 FROM ok");
if( nd>=0 ){
db_multi_exec("%s", blob_str(&sql));
blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
}
| | < < < < | < < < < | < < < | 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
if( d_rid ){
compute_descendants(d_rid, nEntry+1);
nd = db_int(0, "SELECT count(*)-1 FROM ok");
if( nd>=0 ){
db_multi_exec("%s", blob_str(&sql));
blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
}
if( useDividers ) timeline_add_dividers(0, d_rid);
db_multi_exec("DELETE FROM ok");
}
if( p_rid ){
compute_ancestors(p_rid, nEntry+1);
np = db_int(0, "SELECT count(*)-1 FROM ok");
if( np>0 ){
if( nd>0 ) blob_appendf(&desc, " and ");
blob_appendf(&desc, "%d ancestors", np);
db_multi_exec("%s", blob_str(&sql));
}
if( d_rid==0 && useDividers ) timeline_add_dividers(0, p_rid);
}
if( g.okHistory ){
blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>",
g.zTop, zUuid, zUuid);
}else{
blob_appendf(&desc, " of check-in [%.10s]", zUuid);
}
}else if( f_rid && g.okRead ){
/* If f= is present, ignore all other parameters other than n= */
char *zUuid;
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;"
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;",
f_rid, f_rid, f_rid
);
blob_appendf(&sql, " AND event.objid IN ok");
db_multi_exec("%s", blob_str(&sql));
if( useDividers ) timeline_add_dividers(0, f_rid);
blob_appendf(&desc, "Parents and children of check-in ");
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", f_rid);
if( g.okHistory ){
blob_appendf(&desc, "<a href='%s/info/%s'>[%.10s]</a>",
g.zTop, zUuid, zUuid);
}else{
blob_appendf(&desc, "[%.10s]", zUuid);
|
| ︙ | ︙ | |||
934 935 936 937 938 939 940 |
db_multi_exec("%s", blob_str(&sql2));
blob_reset(&sql2);
blob_appendf(&sql,
" AND event.mtime>=%f ORDER BY event.mtime ASC",
rCirca
);
nEntry -= (nEntry+1)/2;
| | | 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
db_multi_exec("%s", blob_str(&sql2));
blob_reset(&sql2);
blob_appendf(&sql,
" AND event.mtime>=%f ORDER BY event.mtime ASC",
rCirca
);
nEntry -= (nEntry+1)/2;
if( useDividers ) timeline_add_dividers(zCirca, 0);
url_add_parameter(&url, "c", zCirca);
}else{
zCirca = 0;
}
}else{
blob_appendf(&sql, " ORDER BY event.mtime DESC");
}
|
| ︙ | ︙ |