Fossil SCM

Add the /cookies page for debugging. (Maybe that page can be expanded to allow users to edit their preferences?) Use sticky values for the "n=" and "y=" query parameters on timelines.

drh 2017-11-28 16:42 UTC sticky-timeline-style
Commit 0f446ca69dfa93ff798920f96fdd9513d4333026045ea55e2f5580834eb496a1
2 files changed +24 -3 +7
+24 -3
--- src/cookies.c
+++ src/cookies.c
@@ -116,11 +116,11 @@
116116
cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1);
117117
return;
118118
}
119119
if( (flags & COOKIE_WRITE)!=0
120120
&& i<COOKIE_NPARAM
121
- && i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue)
121
+ && (i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue))
122122
){
123123
if( i==cookies.nParam ){
124124
cookies.aParam[i].zPName = zPName;
125125
cookies.nParam++;
126126
}
@@ -158,13 +158,34 @@
158158
if( cookies.bChanged ){
159159
Blob new;
160160
int i;
161161
blob_init(&new, 0, 0);
162162
for(i=0;i<cookies.nParam;i++){
163
+ if( i>0 ) blob_append(&new, "&", 1);
163164
blob_appendf(&new, "%s=%t",
164165
cookies.aParam[i].zPName, cookies.aParam[i].zPValue);
165166
}
166167
cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000);
167168
}
168
- fossil_free( cookies.zCookieValue );
169
- memset(&cookies, 0, sizeof(cookies));
169
+ cookies.zCookieName = 0;
170
+}
171
+
172
+/*
173
+** WEBPAGE: cookies
174
+**
175
+** Show the current display settings contained in the
176
+** "fossil_display_settings" cookie.
177
+*/
178
+void cookie_page(void){
179
+ int i;
180
+ cookie_parse("fossil_display_settings");
181
+ style_header("User Preference Cookie Values");
182
+ @ <p>The following are user preference settings held in the
183
+ @ "fossil_display_settings" cookie.
184
+ @ <ul>
185
+ @ <li>Raw cookie value: "%h(PD("fossil_display_settings",""))"
186
+ for(i=0; i<cookies.nParam; i++){
187
+ @ <li>%h(cookies.aParam[i].zPName): "%h(cookies.aParam[i].zPValue)"
188
+ }
189
+ @ </ul>
190
+ style_footer();
170191
}
171192
--- src/cookies.c
+++ src/cookies.c
@@ -116,11 +116,11 @@
116 cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1);
117 return;
118 }
119 if( (flags & COOKIE_WRITE)!=0
120 && i<COOKIE_NPARAM
121 && i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue)
122 ){
123 if( i==cookies.nParam ){
124 cookies.aParam[i].zPName = zPName;
125 cookies.nParam++;
126 }
@@ -158,13 +158,34 @@
158 if( cookies.bChanged ){
159 Blob new;
160 int i;
161 blob_init(&new, 0, 0);
162 for(i=0;i<cookies.nParam;i++){
 
163 blob_appendf(&new, "%s=%t",
164 cookies.aParam[i].zPName, cookies.aParam[i].zPValue);
165 }
166 cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000);
167 }
168 fossil_free( cookies.zCookieValue );
169 memset(&cookies, 0, sizeof(cookies));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170 }
171
--- src/cookies.c
+++ src/cookies.c
@@ -116,11 +116,11 @@
116 cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1);
117 return;
118 }
119 if( (flags & COOKIE_WRITE)!=0
120 && i<COOKIE_NPARAM
121 && (i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue))
122 ){
123 if( i==cookies.nParam ){
124 cookies.aParam[i].zPName = zPName;
125 cookies.nParam++;
126 }
@@ -158,13 +158,34 @@
158 if( cookies.bChanged ){
159 Blob new;
160 int i;
161 blob_init(&new, 0, 0);
162 for(i=0;i<cookies.nParam;i++){
163 if( i>0 ) blob_append(&new, "&", 1);
164 blob_appendf(&new, "%s=%t",
165 cookies.aParam[i].zPName, cookies.aParam[i].zPValue);
166 }
167 cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000);
168 }
169 cookies.zCookieName = 0;
170 }
171
172 /*
173 ** WEBPAGE: cookies
174 **
175 ** Show the current display settings contained in the
176 ** "fossil_display_settings" cookie.
177 */
178 void cookie_page(void){
179 int i;
180 cookie_parse("fossil_display_settings");
181 style_header("User Preference Cookie Values");
182 @ <p>The following are user preference settings held in the
183 @ "fossil_display_settings" cookie.
184 @ <ul>
185 @ <li>Raw cookie value: "%h(PD("fossil_display_settings",""))"
186 for(i=0; i<cookies.nParam; i++){
187 @ <li>%h(cookies.aParam[i].zPName): "%h(cookies.aParam[i].zPValue)"
188 }
189 @ </ul>
190 style_footer();
191 }
192
--- src/timeline.c
+++ src/timeline.c
@@ -1701,10 +1701,12 @@
17011701
char *zNewerButton = 0; /* URL for Newer button at the top */
17021702
int selectedRid = -9999999; /* Show a highlight on this RID */
17031703
int disableY = 0; /* Disable type selector on submenu */
17041704
17051705
/* Set number of rows to display */
1706
+ cookie_parse("fossil_display_settings");
1707
+ cookie_link_parameter("n","tln");
17061708
z = P("n");
17071709
if( z==0 ) z = db_get("timeline-default-length",0);
17081710
if( z ){
17091711
if( fossil_strcmp(z,"all")==0 ){
17101712
nEntry = 0;
@@ -1731,15 +1733,20 @@
17311733
|| (bisectOnly && !g.perm.Setup)
17321734
){
17331735
login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
17341736
return;
17351737
}
1738
+ cookie_read_parameter("y","tly");
17361739
zType = P("y");
17371740
if( zType==0 ){
17381741
zType = g.perm.Read ? "ci" : "all";
17391742
cgi_set_parameter("y", zType);
17401743
}
1744
+ if( zType[0]=='a' || zType[0]=='c' ){
1745
+ cookie_write_parameter("y","tly");
1746
+ }
1747
+ cookie_render();
17411748
url_initialize(&url, "timeline");
17421749
cgi_query_parameters_to_url(&url);
17431750
17441751
/* Convert r=TAG to t=TAG&rel. */
17451752
if( zBrName && !related ){
17461753
--- src/timeline.c
+++ src/timeline.c
@@ -1701,10 +1701,12 @@
1701 char *zNewerButton = 0; /* URL for Newer button at the top */
1702 int selectedRid = -9999999; /* Show a highlight on this RID */
1703 int disableY = 0; /* Disable type selector on submenu */
1704
1705 /* Set number of rows to display */
 
 
1706 z = P("n");
1707 if( z==0 ) z = db_get("timeline-default-length",0);
1708 if( z ){
1709 if( fossil_strcmp(z,"all")==0 ){
1710 nEntry = 0;
@@ -1731,15 +1733,20 @@
1731 || (bisectOnly && !g.perm.Setup)
1732 ){
1733 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
1734 return;
1735 }
 
1736 zType = P("y");
1737 if( zType==0 ){
1738 zType = g.perm.Read ? "ci" : "all";
1739 cgi_set_parameter("y", zType);
1740 }
 
 
 
 
1741 url_initialize(&url, "timeline");
1742 cgi_query_parameters_to_url(&url);
1743
1744 /* Convert r=TAG to t=TAG&rel. */
1745 if( zBrName && !related ){
1746
--- src/timeline.c
+++ src/timeline.c
@@ -1701,10 +1701,12 @@
1701 char *zNewerButton = 0; /* URL for Newer button at the top */
1702 int selectedRid = -9999999; /* Show a highlight on this RID */
1703 int disableY = 0; /* Disable type selector on submenu */
1704
1705 /* Set number of rows to display */
1706 cookie_parse("fossil_display_settings");
1707 cookie_link_parameter("n","tln");
1708 z = P("n");
1709 if( z==0 ) z = db_get("timeline-default-length",0);
1710 if( z ){
1711 if( fossil_strcmp(z,"all")==0 ){
1712 nEntry = 0;
@@ -1731,15 +1733,20 @@
1733 || (bisectOnly && !g.perm.Setup)
1734 ){
1735 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
1736 return;
1737 }
1738 cookie_read_parameter("y","tly");
1739 zType = P("y");
1740 if( zType==0 ){
1741 zType = g.perm.Read ? "ci" : "all";
1742 cgi_set_parameter("y", zType);
1743 }
1744 if( zType[0]=='a' || zType[0]=='c' ){
1745 cookie_write_parameter("y","tly");
1746 }
1747 cookie_render();
1748 url_initialize(&url, "timeline");
1749 cgi_query_parameters_to_url(&url);
1750
1751 /* Convert r=TAG to t=TAG&rel. */
1752 if( zBrName && !related ){
1753

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button