Fossil

Check-in [5af8a1a9]
Login

Check-in [5af8a1a9]

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

Overview
Comment:Allow multiple layers of /skn_X skin specifications at the beginning of the PATH_INFO. Use the last one. Skip over and discard all the others.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5af8a1a937393c81f2b7d276fcc4264f050db69d97b95fe83910452ad3f40f6f
User & Date: drh 2021-01-28 01:01:52
Context
2021-01-28
01:08
Updates to the change log. ... (check-in: 872eb4bc user: drh tags: trunk)
01:01
Allow multiple layers of /skn_X skin specifications at the beginning of the PATH_INFO. Use the last one. Skip over and discard all the others. ... (check-in: 5af8a1a9 user: drh tags: trunk)
2021-01-27
21:12
Add a terse explanation to the /skins page, and a link to /skins from the /sitemap. ... (check-in: 685c7d05 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

1796
1797
1798
1799
1800
1801
1802
1803





1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822


1823
1824
1825
1826
1827
1828
1829


  /*
  ** Check to see if the first term of PATH_INFO specifies an alternative
  ** skin.  This will be the case if the first term of PATH_INFO
  ** begins with "draftN/" where N is an integer between 1 and 9 or
  ** if it is "skn_X/" where X is one of the built-in skin names.
  ** If either is true, then activate the alternative skin.





  */
  if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
   && zPathInfo[6]>='1' && zPathInfo[6]<='9'
   && (zPathInfo[7]=='/' || zPathInfo[7]==0)
  ){
    int iSkin = zPathInfo[6] - '0';
    char *zNewScript;
    skin_use_draft(iSkin);
    zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin);
    if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin);
    if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
    zPathInfo += 7;
    cgi_replace_parameter("PATH_INFO", zPathInfo);
    cgi_replace_parameter("SCRIPT_NAME", zNewScript);
    etag_cancel();
  }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
    int i;
    char *zAlt;
    char *zErr;


    for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
    zAlt = mprintf("%.*s", i-5, zPathInfo+5);
    zErr = skin_use_alternative(zAlt);
    if( zErr ){
      fossil_free(zErr);
    }else{
      char *zNewScript;







|
>
>
>
>
>



















>
>







1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836


  /*
  ** Check to see if the first term of PATH_INFO specifies an alternative
  ** skin.  This will be the case if the first term of PATH_INFO
  ** begins with "draftN/" where N is an integer between 1 and 9 or
  ** if it is "skn_X/" where X is one of the built-in skin names.
  ** If either is true, then activate the alternative skin.a
  **
  ** If there are multiple skn_X entries (ex: /skn_default/skn_ardoise/...)
  ** then skip over all but the last.  This allows one to link to an
  ** alternative skin in hyperlinks even if you are already in an alternative
  ** skin.
  */
  if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
   && zPathInfo[6]>='1' && zPathInfo[6]<='9'
   && (zPathInfo[7]=='/' || zPathInfo[7]==0)
  ){
    int iSkin = zPathInfo[6] - '0';
    char *zNewScript;
    skin_use_draft(iSkin);
    zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin);
    if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin);
    if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
    zPathInfo += 7;
    cgi_replace_parameter("PATH_INFO", zPathInfo);
    cgi_replace_parameter("SCRIPT_NAME", zNewScript);
    etag_cancel();
  }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
    int i;
    char *zAlt;
    char *zErr;
    char *z;
    while( (z = strstr(zPathInfo+1,"/skn_"))!=0 ) zPathInfo = z;
    for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
    zAlt = mprintf("%.*s", i-5, zPathInfo+5);
    zErr = skin_use_alternative(zAlt);
    if( zErr ){
      fossil_free(zErr);
    }else{
      char *zNewScript;