Fossil SCM
On the flat /dir webpage, automatically adjust the number of columns based on the screen width.
Commit
50698a3c277ae7cb2ad55736a64404785fb0f8f3591c92f43048731fdaeec866
Parent
5fb040810e8f8ee…
2 files changed
+3
-13
+9
-6
+3
-13
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -121,11 +121,10 @@ | ||
| 121 | 121 | */ |
| 122 | 122 | void page_dir(void){ |
| 123 | 123 | char *zD = fossil_strdup(P("name")); |
| 124 | 124 | int nD = zD ? strlen(zD)+1 : 0; |
| 125 | 125 | int mxLen; |
| 126 | - int nCol, nRow; | |
| 127 | 126 | int cnt, i; |
| 128 | 127 | char *zPrefix; |
| 129 | 128 | Stmt q; |
| 130 | 129 | const char *zCI = P("ci"); |
| 131 | 130 | int rid = 0; |
| @@ -271,24 +270,15 @@ | ||
| 271 | 270 | ** directory. |
| 272 | 271 | */ |
| 273 | 272 | mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/"); |
| 274 | 273 | cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/"); |
| 275 | 274 | if( mxLen<12 ) mxLen = 12; |
| 276 | - nCol = 100/mxLen; | |
| 277 | - if( nCol<1 ) nCol = 1; | |
| 278 | - if( nCol>5 ) nCol = 5; | |
| 279 | - nRow = (cnt+nCol-1)/nCol; | |
| 280 | 275 | db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/"); |
| 281 | - @ <table class="browser"><tr><td class="browser"><ul class="browser"> | |
| 282 | - i = 0; | |
| 276 | + @ <div class="columns" style="column-width: %d(mxLen)ex;"> | |
| 277 | + @ <ul class="browser"> | |
| 283 | 278 | while( db_step(&q)==SQLITE_ROW ){ |
| 284 | 279 | const char *zFN; |
| 285 | - if( i==nRow ){ | |
| 286 | - @ </ul></td><td class="browser"><ul class="browser"> | |
| 287 | - i = 0; | |
| 288 | - } | |
| 289 | - i++; | |
| 290 | 280 | zFN = db_column_text(&q, 0); |
| 291 | 281 | if( zFN[0]=='/' ){ |
| 292 | 282 | zFN++; |
| 293 | 283 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 294 | 284 | }else{ |
| @@ -302,11 +292,11 @@ | ||
| 302 | 292 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 303 | 293 | } |
| 304 | 294 | } |
| 305 | 295 | db_finalize(&q); |
| 306 | 296 | manifest_destroy(pM); |
| 307 | - @ </ul></td></tr></table> | |
| 297 | + @ </ul></div> | |
| 308 | 298 | |
| 309 | 299 | /* If the directory contains a readme file, then display its content below |
| 310 | 300 | ** the list of files |
| 311 | 301 | */ |
| 312 | 302 | db_prepare(&q, |
| 313 | 303 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -121,11 +121,10 @@ | |
| 121 | */ |
| 122 | void page_dir(void){ |
| 123 | char *zD = fossil_strdup(P("name")); |
| 124 | int nD = zD ? strlen(zD)+1 : 0; |
| 125 | int mxLen; |
| 126 | int nCol, nRow; |
| 127 | int cnt, i; |
| 128 | char *zPrefix; |
| 129 | Stmt q; |
| 130 | const char *zCI = P("ci"); |
| 131 | int rid = 0; |
| @@ -271,24 +270,15 @@ | |
| 271 | ** directory. |
| 272 | */ |
| 273 | mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/"); |
| 274 | cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/"); |
| 275 | if( mxLen<12 ) mxLen = 12; |
| 276 | nCol = 100/mxLen; |
| 277 | if( nCol<1 ) nCol = 1; |
| 278 | if( nCol>5 ) nCol = 5; |
| 279 | nRow = (cnt+nCol-1)/nCol; |
| 280 | db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/"); |
| 281 | @ <table class="browser"><tr><td class="browser"><ul class="browser"> |
| 282 | i = 0; |
| 283 | while( db_step(&q)==SQLITE_ROW ){ |
| 284 | const char *zFN; |
| 285 | if( i==nRow ){ |
| 286 | @ </ul></td><td class="browser"><ul class="browser"> |
| 287 | i = 0; |
| 288 | } |
| 289 | i++; |
| 290 | zFN = db_column_text(&q, 0); |
| 291 | if( zFN[0]=='/' ){ |
| 292 | zFN++; |
| 293 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 294 | }else{ |
| @@ -302,11 +292,11 @@ | |
| 302 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 303 | } |
| 304 | } |
| 305 | db_finalize(&q); |
| 306 | manifest_destroy(pM); |
| 307 | @ </ul></td></tr></table> |
| 308 | |
| 309 | /* If the directory contains a readme file, then display its content below |
| 310 | ** the list of files |
| 311 | */ |
| 312 | db_prepare(&q, |
| 313 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -121,11 +121,10 @@ | |
| 121 | */ |
| 122 | void page_dir(void){ |
| 123 | char *zD = fossil_strdup(P("name")); |
| 124 | int nD = zD ? strlen(zD)+1 : 0; |
| 125 | int mxLen; |
| 126 | int cnt, i; |
| 127 | char *zPrefix; |
| 128 | Stmt q; |
| 129 | const char *zCI = P("ci"); |
| 130 | int rid = 0; |
| @@ -271,24 +270,15 @@ | |
| 270 | ** directory. |
| 271 | */ |
| 272 | mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/"); |
| 273 | cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/"); |
| 274 | if( mxLen<12 ) mxLen = 12; |
| 275 | db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/"); |
| 276 | @ <div class="columns" style="column-width: %d(mxLen)ex;"> |
| 277 | @ <ul class="browser"> |
| 278 | while( db_step(&q)==SQLITE_ROW ){ |
| 279 | const char *zFN; |
| 280 | zFN = db_column_text(&q, 0); |
| 281 | if( zFN[0]=='/' ){ |
| 282 | zFN++; |
| 283 | @ <li class="dir">%z(href("%s%T",zSubdirLink,zFN))%h(zFN)</a></li> |
| 284 | }else{ |
| @@ -302,11 +292,11 @@ | |
| 292 | @ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li> |
| 293 | } |
| 294 | } |
| 295 | db_finalize(&q); |
| 296 | manifest_destroy(pM); |
| 297 | @ </ul></div> |
| 298 | |
| 299 | /* If the directory contains a readme file, then display its content below |
| 300 | ** the list of files |
| 301 | */ |
| 302 | db_prepare(&q, |
| 303 |
+9
-6
| --- src/default_css.txt | ||
| +++ src/default_css.txt | ||
| @@ -184,17 +184,20 @@ | ||
| 184 | 184 | font-weight: bold; |
| 185 | 185 | } |
| 186 | 186 | span.wikiTagCancelled { |
| 187 | 187 | text-decoration: line-through; |
| 188 | 188 | } |
| 189 | -table.browser { | |
| 190 | - width: 100%; | |
| 191 | - border: 0; | |
| 189 | +div.columns { | |
| 190 | + padding: 2em; | |
| 191 | + max-width: 1000px; | |
| 192 | 192 | } |
| 193 | -td.browser { | |
| 194 | - width: 24%; | |
| 195 | - vertical-align: top; | |
| 193 | +div.columns ul { | |
| 194 | + margin: 0; | |
| 195 | + padding: 0; | |
| 196 | +} | |
| 197 | +div.columns ul li:first-child { | |
| 198 | + margin-top:0px; | |
| 196 | 199 | } |
| 197 | 200 | .filetree { |
| 198 | 201 | margin: 1em 0; |
| 199 | 202 | line-height: 1.5; |
| 200 | 203 | } |
| 201 | 204 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -184,17 +184,20 @@ | |
| 184 | font-weight: bold; |
| 185 | } |
| 186 | span.wikiTagCancelled { |
| 187 | text-decoration: line-through; |
| 188 | } |
| 189 | table.browser { |
| 190 | width: 100%; |
| 191 | border: 0; |
| 192 | } |
| 193 | td.browser { |
| 194 | width: 24%; |
| 195 | vertical-align: top; |
| 196 | } |
| 197 | .filetree { |
| 198 | margin: 1em 0; |
| 199 | line-height: 1.5; |
| 200 | } |
| 201 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -184,17 +184,20 @@ | |
| 184 | font-weight: bold; |
| 185 | } |
| 186 | span.wikiTagCancelled { |
| 187 | text-decoration: line-through; |
| 188 | } |
| 189 | div.columns { |
| 190 | padding: 2em; |
| 191 | max-width: 1000px; |
| 192 | } |
| 193 | div.columns ul { |
| 194 | margin: 0; |
| 195 | padding: 0; |
| 196 | } |
| 197 | div.columns ul li:first-child { |
| 198 | margin-top:0px; |
| 199 | } |
| 200 | .filetree { |
| 201 | margin: 1em 0; |
| 202 | line-height: 1.5; |
| 203 | } |
| 204 |