Fossil SCM
Omit "Show associated wikis" from the submenu of a [/wcontent] page if there are no associated wikis in a repository (this amends [29a24941ed9b]). Also optimize out a couple of unnecessary calls to mprintf().
Commit
e3c8aad9b12ac2242fdd649447957b2425be3eb9384c919a77a5ddbd1e13b11f
Parent
114b17c4081090e…
2 files changed
+14
-7
+14
-7
+14
-7
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1918,11 +1918,11 @@ | ||
| 1918 | 1918 | void wcontent_page(void){ |
| 1919 | 1919 | Stmt q; |
| 1920 | 1920 | double rNow; |
| 1921 | 1921 | int showAll = P("all")!=0; |
| 1922 | 1922 | int showRid = P("showid")!=0; |
| 1923 | - int showCkBr = P("showckbr")!=0; | |
| 1923 | + int showCkBr; | |
| 1924 | 1924 | |
| 1925 | 1925 | login_check_credentials(); |
| 1926 | 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | 1927 | style_set_current_feature("wiki"); |
| 1928 | 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | ||
| 1929 | 1929 | if( showAll ){ |
| 1930 | 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | 1931 | }else{ |
| 1932 | 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | 1933 | } |
| 1934 | - style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); | |
| 1934 | + showCkBr = db_exists( | |
| 1935 | + "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " | |
| 1936 | + "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " | |
| 1937 | + " AND TYPEOF(tagxref.value+0)='integer'" ); | |
| 1938 | + if( showCkBr ){ | |
| 1939 | + showCkBr = P("showckbr")!=0; | |
| 1940 | + style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); | |
| 1941 | + } | |
| 1935 | 1942 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1936 | 1943 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1937 | 1944 | @ <div class="brlist"> |
| 1938 | 1945 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1939 | 1946 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | ||
| 1953 | 1960 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1954 | 1961 | char *zAge; |
| 1955 | 1962 | int wcnt = db_column_int(&q, 4); |
| 1956 | 1963 | char *zWDisplayName; |
| 1957 | 1964 | |
| 1965 | + if( !showCkBr && | |
| 1966 | + (sqlite3_strglob("checkin/*", zWName)==0 || | |
| 1967 | + sqlite3_strglob("branch/*", zWName)==0) ){ | |
| 1968 | + continue; | |
| 1969 | + } | |
| 1958 | 1970 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1959 | 1971 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1960 | 1972 | }else{ |
| 1961 | 1973 | zWDisplayName = mprintf("%s", zWName); |
| 1962 | 1974 | } |
| 1963 | - if( !showCkBr && | |
| 1964 | - (sqlite3_strglob("checkin/*", zWName)==0 || | |
| 1965 | - sqlite3_strglob("branch/*", zWName)==0) ){ | |
| 1966 | - continue; | |
| 1967 | - } | |
| 1968 | 1975 | if( wrid==0 ){ |
| 1969 | 1976 | if( !showAll ) continue; |
| 1970 | 1977 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1971 | 1978 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1972 | 1979 | }else{ |
| 1973 | 1980 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1918,11 +1918,11 @@ | |
| 1918 | void wcontent_page(void){ |
| 1919 | Stmt q; |
| 1920 | double rNow; |
| 1921 | int showAll = P("all")!=0; |
| 1922 | int showRid = P("showid")!=0; |
| 1923 | int showCkBr = P("showckbr")!=0; |
| 1924 | |
| 1925 | login_check_credentials(); |
| 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | style_set_current_feature("wiki"); |
| 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | |
| 1929 | if( showAll ){ |
| 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | }else{ |
| 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | } |
| 1934 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1935 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1936 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1937 | @ <div class="brlist"> |
| 1938 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1939 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | |
| 1953 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1954 | char *zAge; |
| 1955 | int wcnt = db_column_int(&q, 4); |
| 1956 | char *zWDisplayName; |
| 1957 | |
| 1958 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1959 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1960 | }else{ |
| 1961 | zWDisplayName = mprintf("%s", zWName); |
| 1962 | } |
| 1963 | if( !showCkBr && |
| 1964 | (sqlite3_strglob("checkin/*", zWName)==0 || |
| 1965 | sqlite3_strglob("branch/*", zWName)==0) ){ |
| 1966 | continue; |
| 1967 | } |
| 1968 | if( wrid==0 ){ |
| 1969 | if( !showAll ) continue; |
| 1970 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1971 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1972 | }else{ |
| 1973 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1918,11 +1918,11 @@ | |
| 1918 | void wcontent_page(void){ |
| 1919 | Stmt q; |
| 1920 | double rNow; |
| 1921 | int showAll = P("all")!=0; |
| 1922 | int showRid = P("showid")!=0; |
| 1923 | int showCkBr; |
| 1924 | |
| 1925 | login_check_credentials(); |
| 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | style_set_current_feature("wiki"); |
| 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | |
| 1929 | if( showAll ){ |
| 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | }else{ |
| 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | } |
| 1934 | showCkBr = db_exists( |
| 1935 | "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " |
| 1936 | "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " |
| 1937 | " AND TYPEOF(tagxref.value+0)='integer'" ); |
| 1938 | if( showCkBr ){ |
| 1939 | showCkBr = P("showckbr")!=0; |
| 1940 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1941 | } |
| 1942 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1943 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1944 | @ <div class="brlist"> |
| 1945 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1946 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | |
| 1960 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1961 | char *zAge; |
| 1962 | int wcnt = db_column_int(&q, 4); |
| 1963 | char *zWDisplayName; |
| 1964 | |
| 1965 | if( !showCkBr && |
| 1966 | (sqlite3_strglob("checkin/*", zWName)==0 || |
| 1967 | sqlite3_strglob("branch/*", zWName)==0) ){ |
| 1968 | continue; |
| 1969 | } |
| 1970 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1971 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1972 | }else{ |
| 1973 | zWDisplayName = mprintf("%s", zWName); |
| 1974 | } |
| 1975 | if( wrid==0 ){ |
| 1976 | if( !showAll ) continue; |
| 1977 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1978 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1979 | }else{ |
| 1980 |
+14
-7
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1918,11 +1918,11 @@ | ||
| 1918 | 1918 | void wcontent_page(void){ |
| 1919 | 1919 | Stmt q; |
| 1920 | 1920 | double rNow; |
| 1921 | 1921 | int showAll = P("all")!=0; |
| 1922 | 1922 | int showRid = P("showid")!=0; |
| 1923 | - int showCkBr = P("showckbr")!=0; | |
| 1923 | + int showCkBr; | |
| 1924 | 1924 | |
| 1925 | 1925 | login_check_credentials(); |
| 1926 | 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | 1927 | style_set_current_feature("wiki"); |
| 1928 | 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | ||
| 1929 | 1929 | if( showAll ){ |
| 1930 | 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | 1931 | }else{ |
| 1932 | 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | 1933 | } |
| 1934 | - style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); | |
| 1934 | + showCkBr = db_exists( | |
| 1935 | + "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " | |
| 1936 | + "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " | |
| 1937 | + " AND TYPEOF(tagxref.value+0)='integer'" ); | |
| 1938 | + if( showCkBr ){ | |
| 1939 | + showCkBr = P("showckbr")!=0; | |
| 1940 | + style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); | |
| 1941 | + } | |
| 1935 | 1942 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1936 | 1943 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1937 | 1944 | @ <div class="brlist"> |
| 1938 | 1945 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1939 | 1946 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | ||
| 1953 | 1960 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1954 | 1961 | char *zAge; |
| 1955 | 1962 | int wcnt = db_column_int(&q, 4); |
| 1956 | 1963 | char *zWDisplayName; |
| 1957 | 1964 | |
| 1965 | + if( !showCkBr && | |
| 1966 | + (sqlite3_strglob("checkin/*", zWName)==0 || | |
| 1967 | + sqlite3_strglob("branch/*", zWName)==0) ){ | |
| 1968 | + continue; | |
| 1969 | + } | |
| 1958 | 1970 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1959 | 1971 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1960 | 1972 | }else{ |
| 1961 | 1973 | zWDisplayName = mprintf("%s", zWName); |
| 1962 | 1974 | } |
| 1963 | - if( !showCkBr && | |
| 1964 | - (sqlite3_strglob("checkin/*", zWName)==0 || | |
| 1965 | - sqlite3_strglob("branch/*", zWName)==0) ){ | |
| 1966 | - continue; | |
| 1967 | - } | |
| 1968 | 1975 | if( wrid==0 ){ |
| 1969 | 1976 | if( !showAll ) continue; |
| 1970 | 1977 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1971 | 1978 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1972 | 1979 | }else{ |
| 1973 | 1980 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1918,11 +1918,11 @@ | |
| 1918 | void wcontent_page(void){ |
| 1919 | Stmt q; |
| 1920 | double rNow; |
| 1921 | int showAll = P("all")!=0; |
| 1922 | int showRid = P("showid")!=0; |
| 1923 | int showCkBr = P("showckbr")!=0; |
| 1924 | |
| 1925 | login_check_credentials(); |
| 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | style_set_current_feature("wiki"); |
| 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | |
| 1929 | if( showAll ){ |
| 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | }else{ |
| 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | } |
| 1934 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1935 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1936 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1937 | @ <div class="brlist"> |
| 1938 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1939 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | |
| 1953 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1954 | char *zAge; |
| 1955 | int wcnt = db_column_int(&q, 4); |
| 1956 | char *zWDisplayName; |
| 1957 | |
| 1958 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1959 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1960 | }else{ |
| 1961 | zWDisplayName = mprintf("%s", zWName); |
| 1962 | } |
| 1963 | if( !showCkBr && |
| 1964 | (sqlite3_strglob("checkin/*", zWName)==0 || |
| 1965 | sqlite3_strglob("branch/*", zWName)==0) ){ |
| 1966 | continue; |
| 1967 | } |
| 1968 | if( wrid==0 ){ |
| 1969 | if( !showAll ) continue; |
| 1970 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1971 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1972 | }else{ |
| 1973 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1918,11 +1918,11 @@ | |
| 1918 | void wcontent_page(void){ |
| 1919 | Stmt q; |
| 1920 | double rNow; |
| 1921 | int showAll = P("all")!=0; |
| 1922 | int showRid = P("showid")!=0; |
| 1923 | int showCkBr; |
| 1924 | |
| 1925 | login_check_credentials(); |
| 1926 | if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
| 1927 | style_set_current_feature("wiki"); |
| 1928 | style_header("Available Wiki Pages"); |
| @@ -1929,11 +1929,18 @@ | |
| 1929 | if( showAll ){ |
| 1930 | style_submenu_element("Active", "%R/wcontent"); |
| 1931 | }else{ |
| 1932 | style_submenu_element("All", "%R/wcontent?all=1"); |
| 1933 | } |
| 1934 | showCkBr = db_exists( |
| 1935 | "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) " |
| 1936 | "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) " |
| 1937 | " AND TYPEOF(tagxref.value+0)='integer'" ); |
| 1938 | if( showCkBr ){ |
| 1939 | showCkBr = P("showckbr")!=0; |
| 1940 | style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0); |
| 1941 | } |
| 1942 | wiki_standard_submenu(W_ALL_BUT(W_LIST)); |
| 1943 | db_prepare(&q, listAllWikiPages/*works-like:""*/); |
| 1944 | @ <div class="brlist"> |
| 1945 | @ <table class='sortable' data-column-types='tKN' data-init-sort='1'> |
| 1946 | @ <thead><tr> |
| @@ -1953,20 +1960,20 @@ | |
| 1960 | sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0); |
| 1961 | char *zAge; |
| 1962 | int wcnt = db_column_int(&q, 4); |
| 1963 | char *zWDisplayName; |
| 1964 | |
| 1965 | if( !showCkBr && |
| 1966 | (sqlite3_strglob("checkin/*", zWName)==0 || |
| 1967 | sqlite3_strglob("branch/*", zWName)==0) ){ |
| 1968 | continue; |
| 1969 | } |
| 1970 | if( sqlite3_strglob("checkin/*", zWName)==0 ){ |
| 1971 | zWDisplayName = mprintf("%.25s...", zWName); |
| 1972 | }else{ |
| 1973 | zWDisplayName = mprintf("%s", zWName); |
| 1974 | } |
| 1975 | if( wrid==0 ){ |
| 1976 | if( !showAll ) continue; |
| 1977 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1978 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1979 | }else{ |
| 1980 |