Fossil SCM
Added menu entry to toggle ln=0 on /info and /artifact pages.
Commit
a5b1bef9cfd605df57788c5459252fa02f4dc18b
Parent
d4acf5c450101f5…
2 files changed
+10
-3
+4
-1
+10
-3
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -365,10 +365,12 @@ | ||
| 365 | 365 | int modPending; /* True if awaiting moderation */ |
| 366 | 366 | const char *zModAction; /* Moderation action or NULL */ |
| 367 | 367 | int isModerator; /* TRUE if user is the moderator */ |
| 368 | 368 | const char *zMime; /* MIME Type */ |
| 369 | 369 | Blob attach; /* Content of the attachment */ |
| 370 | + int fShowContent = 0; | |
| 371 | + const char *zLn = P("ln"); | |
| 370 | 372 | |
| 371 | 373 | login_check_credentials(); |
| 372 | 374 | if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; } |
| 373 | 375 | rid = name_to_rid_www("name"); |
| 374 | 376 | if( rid==0 ){ fossil_redirect_home(); } |
| @@ -391,10 +393,12 @@ | ||
| 391 | 393 | zTarget = pAttach->zAttachTarget; |
| 392 | 394 | zSrc = pAttach->zAttachSrc; |
| 393 | 395 | ridSrc = db_int(0,"SELECT rid FROM blob WHERE uuid='%s'", zSrc); |
| 394 | 396 | zName = pAttach->zAttachName; |
| 395 | 397 | zDesc = pAttach->zComment; |
| 398 | + zMime = mimetype_from_name(zName); | |
| 399 | + fShowContent = zMime ? strncmp(zMime,"text/", 5)==0 : 0; | |
| 396 | 400 | if( validate16(zTarget, strlen(zTarget)) |
| 397 | 401 | && db_exists("SELECT 1 FROM ticket WHERE tkt_uuid='%s'", zTarget) |
| 398 | 402 | ){ |
| 399 | 403 | zTktUuid = zTarget; |
| 400 | 404 | if( !g.perm.RdTkt ){ login_needed(); return; } |
| @@ -464,10 +468,15 @@ | ||
| 464 | 468 | moderation_approve(rid); |
| 465 | 469 | } |
| 466 | 470 | } |
| 467 | 471 | style_header("Attachment Details"); |
| 468 | 472 | style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid); |
| 473 | + if(fShowContent){ | |
| 474 | + style_submenu_element("Line Numbers", "Line Numbers", | |
| 475 | + "%R/ainfo/%s%s",zUuid, | |
| 476 | + ((zLn&&*zLn) ? "" : "?ln=0")); | |
| 477 | + } | |
| 469 | 478 | |
| 470 | 479 | @ <div class="section">Overview</div> |
| 471 | 480 | @ <p><table class="label-value"> |
| 472 | 481 | @ <tr><th>Artifact ID:</th> |
| 473 | 482 | @ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a> |
| @@ -494,11 +503,10 @@ | ||
| 494 | 503 | @ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a> |
| 495 | 504 | if( g.perm.Setup ){ |
| 496 | 505 | @ (%d(ridSrc)) |
| 497 | 506 | } |
| 498 | 507 | @ <tr><th>Filename:</th><td>%h(zName)</td></tr> |
| 499 | - zMime = mimetype_from_name(zName); | |
| 500 | 508 | if( g.perm.Setup ){ |
| 501 | 509 | @ <tr><th>MIME-Type:</th><td>%h(zMime)</td></tr> |
| 502 | 510 | } |
| 503 | 511 | @ <tr><th valign="top">Description:</th><td valign="top">%h(zDesc)</td></tr> |
| 504 | 512 | @ </table> |
| @@ -517,13 +525,12 @@ | ||
| 517 | 525 | } |
| 518 | 526 | |
| 519 | 527 | @ <div class="section">Content Appended</div> |
| 520 | 528 | @ <blockquote> |
| 521 | 529 | blob_zero(&attach); |
| 522 | - if( zMime==0 || strncmp(zMime,"text/", 5)==0 ){ | |
| 530 | + if( fShowContent ){ | |
| 523 | 531 | const char *z; |
| 524 | - const char *zLn = P("ln"); | |
| 525 | 532 | content_get(ridSrc, &attach); |
| 526 | 533 | blob_to_utf8_no_bom(&attach, 0); |
| 527 | 534 | z = blob_str(&attach); |
| 528 | 535 | if( zLn ){ |
| 529 | 536 | output_text_with_line_numbers(z, zLn); |
| 530 | 537 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -365,10 +365,12 @@ | |
| 365 | int modPending; /* True if awaiting moderation */ |
| 366 | const char *zModAction; /* Moderation action or NULL */ |
| 367 | int isModerator; /* TRUE if user is the moderator */ |
| 368 | const char *zMime; /* MIME Type */ |
| 369 | Blob attach; /* Content of the attachment */ |
| 370 | |
| 371 | login_check_credentials(); |
| 372 | if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; } |
| 373 | rid = name_to_rid_www("name"); |
| 374 | if( rid==0 ){ fossil_redirect_home(); } |
| @@ -391,10 +393,12 @@ | |
| 391 | zTarget = pAttach->zAttachTarget; |
| 392 | zSrc = pAttach->zAttachSrc; |
| 393 | ridSrc = db_int(0,"SELECT rid FROM blob WHERE uuid='%s'", zSrc); |
| 394 | zName = pAttach->zAttachName; |
| 395 | zDesc = pAttach->zComment; |
| 396 | if( validate16(zTarget, strlen(zTarget)) |
| 397 | && db_exists("SELECT 1 FROM ticket WHERE tkt_uuid='%s'", zTarget) |
| 398 | ){ |
| 399 | zTktUuid = zTarget; |
| 400 | if( !g.perm.RdTkt ){ login_needed(); return; } |
| @@ -464,10 +468,15 @@ | |
| 464 | moderation_approve(rid); |
| 465 | } |
| 466 | } |
| 467 | style_header("Attachment Details"); |
| 468 | style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid); |
| 469 | |
| 470 | @ <div class="section">Overview</div> |
| 471 | @ <p><table class="label-value"> |
| 472 | @ <tr><th>Artifact ID:</th> |
| 473 | @ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a> |
| @@ -494,11 +503,10 @@ | |
| 494 | @ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a> |
| 495 | if( g.perm.Setup ){ |
| 496 | @ (%d(ridSrc)) |
| 497 | } |
| 498 | @ <tr><th>Filename:</th><td>%h(zName)</td></tr> |
| 499 | zMime = mimetype_from_name(zName); |
| 500 | if( g.perm.Setup ){ |
| 501 | @ <tr><th>MIME-Type:</th><td>%h(zMime)</td></tr> |
| 502 | } |
| 503 | @ <tr><th valign="top">Description:</th><td valign="top">%h(zDesc)</td></tr> |
| 504 | @ </table> |
| @@ -517,13 +525,12 @@ | |
| 517 | } |
| 518 | |
| 519 | @ <div class="section">Content Appended</div> |
| 520 | @ <blockquote> |
| 521 | blob_zero(&attach); |
| 522 | if( zMime==0 || strncmp(zMime,"text/", 5)==0 ){ |
| 523 | const char *z; |
| 524 | const char *zLn = P("ln"); |
| 525 | content_get(ridSrc, &attach); |
| 526 | blob_to_utf8_no_bom(&attach, 0); |
| 527 | z = blob_str(&attach); |
| 528 | if( zLn ){ |
| 529 | output_text_with_line_numbers(z, zLn); |
| 530 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -365,10 +365,12 @@ | |
| 365 | int modPending; /* True if awaiting moderation */ |
| 366 | const char *zModAction; /* Moderation action or NULL */ |
| 367 | int isModerator; /* TRUE if user is the moderator */ |
| 368 | const char *zMime; /* MIME Type */ |
| 369 | Blob attach; /* Content of the attachment */ |
| 370 | int fShowContent = 0; |
| 371 | const char *zLn = P("ln"); |
| 372 | |
| 373 | login_check_credentials(); |
| 374 | if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; } |
| 375 | rid = name_to_rid_www("name"); |
| 376 | if( rid==0 ){ fossil_redirect_home(); } |
| @@ -391,10 +393,12 @@ | |
| 393 | zTarget = pAttach->zAttachTarget; |
| 394 | zSrc = pAttach->zAttachSrc; |
| 395 | ridSrc = db_int(0,"SELECT rid FROM blob WHERE uuid='%s'", zSrc); |
| 396 | zName = pAttach->zAttachName; |
| 397 | zDesc = pAttach->zComment; |
| 398 | zMime = mimetype_from_name(zName); |
| 399 | fShowContent = zMime ? strncmp(zMime,"text/", 5)==0 : 0; |
| 400 | if( validate16(zTarget, strlen(zTarget)) |
| 401 | && db_exists("SELECT 1 FROM ticket WHERE tkt_uuid='%s'", zTarget) |
| 402 | ){ |
| 403 | zTktUuid = zTarget; |
| 404 | if( !g.perm.RdTkt ){ login_needed(); return; } |
| @@ -464,10 +468,15 @@ | |
| 468 | moderation_approve(rid); |
| 469 | } |
| 470 | } |
| 471 | style_header("Attachment Details"); |
| 472 | style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid); |
| 473 | if(fShowContent){ |
| 474 | style_submenu_element("Line Numbers", "Line Numbers", |
| 475 | "%R/ainfo/%s%s",zUuid, |
| 476 | ((zLn&&*zLn) ? "" : "?ln=0")); |
| 477 | } |
| 478 | |
| 479 | @ <div class="section">Overview</div> |
| 480 | @ <p><table class="label-value"> |
| 481 | @ <tr><th>Artifact ID:</th> |
| 482 | @ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a> |
| @@ -494,11 +503,10 @@ | |
| 503 | @ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a> |
| 504 | if( g.perm.Setup ){ |
| 505 | @ (%d(ridSrc)) |
| 506 | } |
| 507 | @ <tr><th>Filename:</th><td>%h(zName)</td></tr> |
| 508 | if( g.perm.Setup ){ |
| 509 | @ <tr><th>MIME-Type:</th><td>%h(zMime)</td></tr> |
| 510 | } |
| 511 | @ <tr><th valign="top">Description:</th><td valign="top">%h(zDesc)</td></tr> |
| 512 | @ </table> |
| @@ -517,13 +525,12 @@ | |
| 525 | } |
| 526 | |
| 527 | @ <div class="section">Content Appended</div> |
| 528 | @ <blockquote> |
| 529 | blob_zero(&attach); |
| 530 | if( fShowContent ){ |
| 531 | const char *z; |
| 532 | content_get(ridSrc, &attach); |
| 533 | blob_to_utf8_no_bom(&attach, 0); |
| 534 | z = blob_str(&attach); |
| 535 | if( zLn ){ |
| 536 | output_text_with_line_numbers(z, zLn); |
| 537 |
+4
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1744,10 +1744,11 @@ | ||
| 1744 | 1744 | int objType; |
| 1745 | 1745 | int asText; |
| 1746 | 1746 | const char *zUuid; |
| 1747 | 1747 | u32 objdescFlags = 0; |
| 1748 | 1748 | int descOnly = fossil_strcmp(g.zPath,"whatis")==0; |
| 1749 | + const char *zLn = P("ln"); | |
| 1749 | 1750 | |
| 1750 | 1751 | if( P("ci") && P("filename") ){ |
| 1751 | 1752 | rid = artifact_from_ci_and_filename_www(); |
| 1752 | 1753 | } |
| 1753 | 1754 | if( rid==0 ){ |
| @@ -1811,10 +1812,13 @@ | ||
| 1811 | 1812 | style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid); |
| 1812 | 1813 | } |
| 1813 | 1814 | if( descOnly ){ |
| 1814 | 1815 | style_submenu_element("Content", "Content", "%R/artifact/%s", zUuid); |
| 1815 | 1816 | }else{ |
| 1817 | + style_submenu_element("Line Numbers", "Line Numbers", | |
| 1818 | + "%R/info/%s%s",zUuid, | |
| 1819 | + ((zLn&&*zLn) ? "" : "?ln=0")); | |
| 1816 | 1820 | @ <hr /> |
| 1817 | 1821 | content_get(rid, &content); |
| 1818 | 1822 | if( renderAsWiki ){ |
| 1819 | 1823 | wiki_render_by_mimetype(&content, zMime); |
| 1820 | 1824 | }else if( renderAsHtml ){ |
| @@ -1827,11 +1831,10 @@ | ||
| 1827 | 1831 | style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid); |
| 1828 | 1832 | blob_to_utf8_no_bom(&content, 0); |
| 1829 | 1833 | zMime = mimetype_from_content(&content); |
| 1830 | 1834 | @ <blockquote> |
| 1831 | 1835 | if( zMime==0 ){ |
| 1832 | - const char *zLn = P("ln"); | |
| 1833 | 1836 | const char *z; |
| 1834 | 1837 | z = blob_str(&content); |
| 1835 | 1838 | if( zLn ){ |
| 1836 | 1839 | output_text_with_line_numbers(z, zLn); |
| 1837 | 1840 | }else{ |
| 1838 | 1841 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1744,10 +1744,11 @@ | |
| 1744 | int objType; |
| 1745 | int asText; |
| 1746 | const char *zUuid; |
| 1747 | u32 objdescFlags = 0; |
| 1748 | int descOnly = fossil_strcmp(g.zPath,"whatis")==0; |
| 1749 | |
| 1750 | if( P("ci") && P("filename") ){ |
| 1751 | rid = artifact_from_ci_and_filename_www(); |
| 1752 | } |
| 1753 | if( rid==0 ){ |
| @@ -1811,10 +1812,13 @@ | |
| 1811 | style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid); |
| 1812 | } |
| 1813 | if( descOnly ){ |
| 1814 | style_submenu_element("Content", "Content", "%R/artifact/%s", zUuid); |
| 1815 | }else{ |
| 1816 | @ <hr /> |
| 1817 | content_get(rid, &content); |
| 1818 | if( renderAsWiki ){ |
| 1819 | wiki_render_by_mimetype(&content, zMime); |
| 1820 | }else if( renderAsHtml ){ |
| @@ -1827,11 +1831,10 @@ | |
| 1827 | style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid); |
| 1828 | blob_to_utf8_no_bom(&content, 0); |
| 1829 | zMime = mimetype_from_content(&content); |
| 1830 | @ <blockquote> |
| 1831 | if( zMime==0 ){ |
| 1832 | const char *zLn = P("ln"); |
| 1833 | const char *z; |
| 1834 | z = blob_str(&content); |
| 1835 | if( zLn ){ |
| 1836 | output_text_with_line_numbers(z, zLn); |
| 1837 | }else{ |
| 1838 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1744,10 +1744,11 @@ | |
| 1744 | int objType; |
| 1745 | int asText; |
| 1746 | const char *zUuid; |
| 1747 | u32 objdescFlags = 0; |
| 1748 | int descOnly = fossil_strcmp(g.zPath,"whatis")==0; |
| 1749 | const char *zLn = P("ln"); |
| 1750 | |
| 1751 | if( P("ci") && P("filename") ){ |
| 1752 | rid = artifact_from_ci_and_filename_www(); |
| 1753 | } |
| 1754 | if( rid==0 ){ |
| @@ -1811,10 +1812,13 @@ | |
| 1812 | style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid); |
| 1813 | } |
| 1814 | if( descOnly ){ |
| 1815 | style_submenu_element("Content", "Content", "%R/artifact/%s", zUuid); |
| 1816 | }else{ |
| 1817 | style_submenu_element("Line Numbers", "Line Numbers", |
| 1818 | "%R/info/%s%s",zUuid, |
| 1819 | ((zLn&&*zLn) ? "" : "?ln=0")); |
| 1820 | @ <hr /> |
| 1821 | content_get(rid, &content); |
| 1822 | if( renderAsWiki ){ |
| 1823 | wiki_render_by_mimetype(&content, zMime); |
| 1824 | }else if( renderAsHtml ){ |
| @@ -1827,11 +1831,10 @@ | |
| 1831 | style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid); |
| 1832 | blob_to_utf8_no_bom(&content, 0); |
| 1833 | zMime = mimetype_from_content(&content); |
| 1834 | @ <blockquote> |
| 1835 | if( zMime==0 ){ |
| 1836 | const char *z; |
| 1837 | z = blob_str(&content); |
| 1838 | if( zLn ){ |
| 1839 | output_text_with_line_numbers(z, zLn); |
| 1840 | }else{ |
| 1841 |