Fossil SCM

If the first term of the PATH_INFO is "skn_X" where X is one of the built-in skin names, then use that built-in skin rather than whatever is configured.

drh 2021-01-27 17:22 trunk
Commit 7b028d74a6acd6d5794d78ef00e280208b23cf4ebfa277702bd1eaaa6f23075f
1 file changed +29 -4
+29 -4
--- src/main.c
+++ src/main.c
@@ -1790,13 +1790,19 @@
17901790
}
17911791
}
17921792
17931793
/* At this point, the appropriate repository database file will have
17941794
** been opened.
1795
- **
1796
- ** Check to see if the PATH_INFO begins with "draft[1-9]" and if
1797
- ** so activate the special handling for draft skins
1795
+ */
1796
+
1797
+
1798
+ /*
1799
+ ** Check to see if the first term of PATH_INFO specifies an alternative
1800
+ ** skin. This will be the case if the first term of PATH_INFO
1801
+ ** begins with "draftN/" where N is an integer between 1 and 9 or
1802
+ ** if it is "skn_X/" where X is one of the built-in skin names.
1803
+ ** If either is true, then activate the alternative skin.
17981804
*/
17991805
if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
18001806
&& zPathInfo[6]>='1' && zPathInfo[6]<='9'
18011807
&& (zPathInfo[7]=='/' || zPathInfo[7]==0)
18021808
){
@@ -1808,11 +1814,30 @@
18081814
if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
18091815
zPathInfo += 7;
18101816
cgi_replace_parameter("PATH_INFO", zPathInfo);
18111817
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
18121818
etag_cancel();
1813
- }
1819
+ }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
1820
+ int i;
1821
+ char *zAlt;
1822
+ char *zErr;
1823
+ for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
1824
+ zAlt = mprintf("%.*s", i-5, zPathInfo+5);
1825
+ zErr = skin_use_alternative(zAlt);
1826
+ if( zErr ){
1827
+ fossil_free(zErr);
1828
+ }else{
1829
+ char *zNewScript;
1830
+ zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt);
1831
+ if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt);
1832
+ if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt);
1833
+ zPathInfo += i;
1834
+ cgi_replace_parameter("PATH_INFO", zPathInfo);
1835
+ cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1836
+ }
1837
+ fossil_free(zAlt);
1838
+ }
18141839
18151840
/* If the content type is application/x-fossil or
18161841
** application/x-fossil-debug, then a sync/push/pull/clone is
18171842
** desired, so default the PATH_INFO to /xfer
18181843
*/
18191844
--- src/main.c
+++ src/main.c
@@ -1790,13 +1790,19 @@
1790 }
1791 }
1792
1793 /* At this point, the appropriate repository database file will have
1794 ** been opened.
1795 **
1796 ** Check to see if the PATH_INFO begins with "draft[1-9]" and if
1797 ** so activate the special handling for draft skins
 
 
 
 
 
 
1798 */
1799 if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
1800 && zPathInfo[6]>='1' && zPathInfo[6]<='9'
1801 && (zPathInfo[7]=='/' || zPathInfo[7]==0)
1802 ){
@@ -1808,11 +1814,30 @@
1808 if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
1809 zPathInfo += 7;
1810 cgi_replace_parameter("PATH_INFO", zPathInfo);
1811 cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1812 etag_cancel();
1813 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1814
1815 /* If the content type is application/x-fossil or
1816 ** application/x-fossil-debug, then a sync/push/pull/clone is
1817 ** desired, so default the PATH_INFO to /xfer
1818 */
1819
--- src/main.c
+++ src/main.c
@@ -1790,13 +1790,19 @@
1790 }
1791 }
1792
1793 /* At this point, the appropriate repository database file will have
1794 ** been opened.
1795 */
1796
1797
1798 /*
1799 ** Check to see if the first term of PATH_INFO specifies an alternative
1800 ** skin. This will be the case if the first term of PATH_INFO
1801 ** begins with "draftN/" where N is an integer between 1 and 9 or
1802 ** if it is "skn_X/" where X is one of the built-in skin names.
1803 ** If either is true, then activate the alternative skin.
1804 */
1805 if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
1806 && zPathInfo[6]>='1' && zPathInfo[6]<='9'
1807 && (zPathInfo[7]=='/' || zPathInfo[7]==0)
1808 ){
@@ -1808,11 +1814,30 @@
1814 if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
1815 zPathInfo += 7;
1816 cgi_replace_parameter("PATH_INFO", zPathInfo);
1817 cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1818 etag_cancel();
1819 }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
1820 int i;
1821 char *zAlt;
1822 char *zErr;
1823 for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
1824 zAlt = mprintf("%.*s", i-5, zPathInfo+5);
1825 zErr = skin_use_alternative(zAlt);
1826 if( zErr ){
1827 fossil_free(zErr);
1828 }else{
1829 char *zNewScript;
1830 zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt);
1831 if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt);
1832 if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt);
1833 zPathInfo += i;
1834 cgi_replace_parameter("PATH_INFO", zPathInfo);
1835 cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1836 }
1837 fossil_free(zAlt);
1838 }
1839
1840 /* If the content type is application/x-fossil or
1841 ** application/x-fossil-debug, then a sync/push/pull/clone is
1842 ** desired, so default the PATH_INFO to /xfer
1843 */
1844

Keyboard Shortcuts

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