Fossil

Check-in [0f446ca6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sticky-timeline-style
Files: files | file ages | folders
SHA3-256:0f446ca69dfa93ff798920f96fdd9513d4333026045ea55e2f5580834eb496a1
User & Date: drh 2017-11-28 16:42:43
Context
2017-11-28
19:41
Work toward getting the mode selector to work on /timeline. This check-in is incomplete and is intended only to transfer code between machines. check-in: fdf071e1 user: drh tags: sticky-timeline-style
16:42
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. check-in: 0f446ca6 user: drh tags: sticky-timeline-style
15:42
The intent of this branch is to refactor /timeline comment rendering, giving the user multiple display options, and making the option sticky in the sense that the option selected most recently becomes the new default. This is an incremental check-in containing infrastructure cookie-handling logic. check-in: bc8947d1 user: drh tags: sticky-timeline-style
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/cookies.c.

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170





















  for(i=0; i<cookies.nParam && strcmp(zPName,cookies.aParam[i].zPName); i++){}
  if( (flags & COOKIE_READ)!=0 && zQVal==0 && i<cookies.nParam ){
    cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1);
    return;
  }
  if( (flags & COOKIE_WRITE)!=0
   && i<COOKIE_NPARAM
   && i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue)
  ){
    if( i==cookies.nParam ){
      cookies.aParam[i].zPName = zPName;
      cookies.nParam++;
    }
    cookies.aParam[i].zPValue = (char*)zQVal;
    cookies.bChanged = 1;
................................................................................
void cookie_render(void){
  assert( cookies.zCookieName!=0 );
  if( cookies.bChanged ){
    Blob new;
    int i;
    blob_init(&new, 0, 0);
    for(i=0;i<cookies.nParam;i++){

      blob_appendf(&new, "%s=%t",
          cookies.aParam[i].zPName, cookies.aParam[i].zPValue);
    }
    cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000);
  }
  fossil_free( cookies.zCookieValue );
  memset(&cookies, 0, sizeof(cookies));
}




























|







 







>





|
<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  for(i=0; i<cookies.nParam && strcmp(zPName,cookies.aParam[i].zPName); i++){}
  if( (flags & COOKIE_READ)!=0 && zQVal==0 && i<cookies.nParam ){
    cgi_set_parameter_nocopy(zQP, cookies.aParam[i].zPValue, 1);
    return;
  }
  if( (flags & COOKIE_WRITE)!=0
   && i<COOKIE_NPARAM
   && (i==cookies.nParam || strcmp(zQVal, cookies.aParam[i].zPValue))
  ){
    if( i==cookies.nParam ){
      cookies.aParam[i].zPName = zPName;
      cookies.nParam++;
    }
    cookies.aParam[i].zPValue = (char*)zQVal;
    cookies.bChanged = 1;
................................................................................
void cookie_render(void){
  assert( cookies.zCookieName!=0 );
  if( cookies.bChanged ){
    Blob new;
    int i;
    blob_init(&new, 0, 0);
    for(i=0;i<cookies.nParam;i++){
      if( i>0 ) blob_append(&new, "&", 1);
      blob_appendf(&new, "%s=%t",
          cookies.aParam[i].zPName, cookies.aParam[i].zPValue);
    }
    cgi_set_cookie(cookies.zCookieName, blob_str(&new), 0, 31536000);
  }
  cookies.zCookieName = 0;

}

/*
** WEBPAGE:  cookies
**
** Show the current display settings contained in the
** "fossil_display_settings" cookie.
*/
void cookie_page(void){
  int i;
  cookie_parse("fossil_display_settings");
  style_header("User Preference Cookie Values");
  @ <p>The following are user preference settings held in the
  @ "fossil_display_settings" cookie.
  @ <ul>
  @ <li>Raw cookie value: "%h(PD("fossil_display_settings",""))"
  for(i=0; i<cookies.nParam; i++){
    @ <li>%h(cookies.aParam[i].zPName): "%h(cookies.aParam[i].zPValue)"
  }
  @ </ul>
  style_footer();
}

Changes to src/timeline.c.

1699
1700
1701
1702
1703
1704
1705


1706
1707
1708
1709
1710
1711
1712
....
1729
1730
1731
1732
1733
1734
1735

1736
1737
1738
1739
1740




1741
1742
1743
1744
1745
1746
1747
  const char *z;
  char *zOlderButton = 0;             /* URL for Older button at the bottom */
  char *zNewerButton = 0;             /* URL for Newer button at the top */
  int selectedRid = -9999999;         /* Show a highlight on this RID */
  int disableY = 0;                   /* Disable type selector on submenu */

  /* Set number of rows to display */


  z = P("n");
  if( z==0 ) z = db_get("timeline-default-length",0);
  if( z ){
    if( fossil_strcmp(z,"all")==0 ){
      nEntry = 0;
    }else{
      nEntry = atoi(z);
................................................................................
  login_check_credentials();
  if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki)
   || (bisectOnly && !g.perm.Setup)
  ){
    login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
    return;
  }

  zType = P("y");
  if( zType==0 ){
    zType = g.perm.Read ? "ci" : "all";
    cgi_set_parameter("y", zType);
  }




  url_initialize(&url, "timeline");
  cgi_query_parameters_to_url(&url);

  /* Convert r=TAG to t=TAG&rel. */
  if( zBrName && !related ){
    cgi_delete_query_parameter("r");
    cgi_set_query_parameter("t", zBrName);







>
>







 







>





>
>
>
>







1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
....
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
  const char *z;
  char *zOlderButton = 0;             /* URL for Older button at the bottom */
  char *zNewerButton = 0;             /* URL for Newer button at the top */
  int selectedRid = -9999999;         /* Show a highlight on this RID */
  int disableY = 0;                   /* Disable type selector on submenu */

  /* Set number of rows to display */
  cookie_parse("fossil_display_settings");
  cookie_link_parameter("n","tln");
  z = P("n");
  if( z==0 ) z = db_get("timeline-default-length",0);
  if( z ){
    if( fossil_strcmp(z,"all")==0 ){
      nEntry = 0;
    }else{
      nEntry = atoi(z);
................................................................................
  login_check_credentials();
  if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki)
   || (bisectOnly && !g.perm.Setup)
  ){
    login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
    return;
  }
  cookie_read_parameter("y","tly");
  zType = P("y");
  if( zType==0 ){
    zType = g.perm.Read ? "ci" : "all";
    cgi_set_parameter("y", zType);
  }
  if( zType[0]=='a' || zType[0]=='c' ){
    cookie_write_parameter("y","tly");
  }
  cookie_render();
  url_initialize(&url, "timeline");
  cgi_query_parameters_to_url(&url);

  /* Convert r=TAG to t=TAG&rel. */
  if( zBrName && !related ){
    cgi_delete_query_parameter("r");
    cgi_set_query_parameter("t", zBrName);