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.
Commit
0f446ca69dfa93ff798920f96fdd9513d4333026045ea55e2f5580834eb496a1
Parent
bc8947d1dc097cd…
2 files changed
+24
-3
+7
+24
-3
| --- src/cookies.c | ||
| +++ src/cookies.c | ||
| @@ -116,11 +116,11 @@ | ||
| 116 | 116 | cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1); |
| 117 | 117 | return; |
| 118 | 118 | } |
| 119 | 119 | if( (flags & COOKIE_WRITE)!=0 |
| 120 | 120 | && i<COOKIE_NPARAM |
| 121 | - && i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue) | |
| 121 | + && (i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue)) | |
| 122 | 122 | ){ |
| 123 | 123 | if( i==cookies.nParam ){ |
| 124 | 124 | cookies.aParam[i].zPName = zPName; |
| 125 | 125 | cookies.nParam++; |
| 126 | 126 | } |
| @@ -158,13 +158,34 @@ | ||
| 158 | 158 | if( cookies.bChanged ){ |
| 159 | 159 | Blob new; |
| 160 | 160 | int i; |
| 161 | 161 | blob_init(&new, 0, 0); |
| 162 | 162 | for(i=0;i<cookies.nParam;i++){ |
| 163 | + if( i>0 ) blob_append(&new, "&", 1); | |
| 163 | 164 | blob_appendf(&new, "%s=%t", |
| 164 | 165 | cookies.aParam[i].zPName, cookies.aParam[i].zPValue); |
| 165 | 166 | } |
| 166 | 167 | cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000); |
| 167 | 168 | } |
| 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(); | |
| 170 | 191 | } |
| 171 | 192 |
| --- 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 |
+7
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1701,10 +1701,12 @@ | ||
| 1701 | 1701 | char *zNewerButton = 0; /* URL for Newer button at the top */ |
| 1702 | 1702 | int selectedRid = -9999999; /* Show a highlight on this RID */ |
| 1703 | 1703 | int disableY = 0; /* Disable type selector on submenu */ |
| 1704 | 1704 | |
| 1705 | 1705 | /* Set number of rows to display */ |
| 1706 | + cookie_parse("fossil_display_settings"); | |
| 1707 | + cookie_link_parameter("n","tln"); | |
| 1706 | 1708 | z = P("n"); |
| 1707 | 1709 | if( z==0 ) z = db_get("timeline-default-length",0); |
| 1708 | 1710 | if( z ){ |
| 1709 | 1711 | if( fossil_strcmp(z,"all")==0 ){ |
| 1710 | 1712 | nEntry = 0; |
| @@ -1731,15 +1733,20 @@ | ||
| 1731 | 1733 | || (bisectOnly && !g.perm.Setup) |
| 1732 | 1734 | ){ |
| 1733 | 1735 | login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki); |
| 1734 | 1736 | return; |
| 1735 | 1737 | } |
| 1738 | + cookie_read_parameter("y","tly"); | |
| 1736 | 1739 | zType = P("y"); |
| 1737 | 1740 | if( zType==0 ){ |
| 1738 | 1741 | zType = g.perm.Read ? "ci" : "all"; |
| 1739 | 1742 | cgi_set_parameter("y", zType); |
| 1740 | 1743 | } |
| 1744 | + if( zType[0]=='a' || zType[0]=='c' ){ | |
| 1745 | + cookie_write_parameter("y","tly"); | |
| 1746 | + } | |
| 1747 | + cookie_render(); | |
| 1741 | 1748 | url_initialize(&url, "timeline"); |
| 1742 | 1749 | cgi_query_parameters_to_url(&url); |
| 1743 | 1750 | |
| 1744 | 1751 | /* Convert r=TAG to t=TAG&rel. */ |
| 1745 | 1752 | if( zBrName && !related ){ |
| 1746 | 1753 |
| --- 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 |