Fossil SCM

Added menu entry to toggle ln=0 on /info and /artifact pages.

stephan 2014-08-27 16:20 UTC trunk
Commit a5b1bef9cfd605df57788c5459252fa02f4dc18b
2 files changed +10 -3 +4 -1
+10 -3
--- src/attach.c
+++ src/attach.c
@@ -365,10 +365,12 @@
365365
int modPending; /* True if awaiting moderation */
366366
const char *zModAction; /* Moderation action or NULL */
367367
int isModerator; /* TRUE if user is the moderator */
368368
const char *zMime; /* MIME Type */
369369
Blob attach; /* Content of the attachment */
370
+ int fShowContent = 0;
371
+ const char *zLn = P("ln");
370372
371373
login_check_credentials();
372374
if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; }
373375
rid = name_to_rid_www("name");
374376
if( rid==0 ){ fossil_redirect_home(); }
@@ -391,10 +393,12 @@
391393
zTarget = pAttach->zAttachTarget;
392394
zSrc = pAttach->zAttachSrc;
393395
ridSrc = db_int(0,"SELECT rid FROM blob WHERE uuid='%s'", zSrc);
394396
zName = pAttach->zAttachName;
395397
zDesc = pAttach->zComment;
398
+ zMime = mimetype_from_name(zName);
399
+ fShowContent = zMime ? strncmp(zMime,"text/", 5)==0 : 0;
396400
if( validate16(zTarget, strlen(zTarget))
397401
&& db_exists("SELECT 1 FROM ticket WHERE tkt_uuid='%s'", zTarget)
398402
){
399403
zTktUuid = zTarget;
400404
if( !g.perm.RdTkt ){ login_needed(); return; }
@@ -464,10 +468,15 @@
464468
moderation_approve(rid);
465469
}
466470
}
467471
style_header("Attachment Details");
468472
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
+ }
469478
470479
@ <div class="section">Overview</div>
471480
@ <p><table class="label-value">
472481
@ <tr><th>Artifact&nbsp;ID:</th>
473482
@ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a>
@@ -494,11 +503,10 @@
494503
@ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a>
495504
if( g.perm.Setup ){
496505
@ (%d(ridSrc))
497506
}
498507
@ <tr><th>Filename:</th><td>%h(zName)</td></tr>
499
- zMime = mimetype_from_name(zName);
500508
if( g.perm.Setup ){
501509
@ <tr><th>MIME-Type:</th><td>%h(zMime)</td></tr>
502510
}
503511
@ <tr><th valign="top">Description:</th><td valign="top">%h(zDesc)</td></tr>
504512
@ </table>
@@ -517,13 +525,12 @@
517525
}
518526
519527
@ <div class="section">Content Appended</div>
520528
@ <blockquote>
521529
blob_zero(&attach);
522
- if( zMime==0 || strncmp(zMime,"text/", 5)==0 ){
530
+ if( fShowContent ){
523531
const char *z;
524
- const char *zLn = P("ln");
525532
content_get(ridSrc, &attach);
526533
blob_to_utf8_no_bom(&attach, 0);
527534
z = blob_str(&attach);
528535
if( zLn ){
529536
output_text_with_line_numbers(z, zLn);
530537
--- 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&nbsp;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&nbsp;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 @@
17441744
int objType;
17451745
int asText;
17461746
const char *zUuid;
17471747
u32 objdescFlags = 0;
17481748
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
1749
+ const char *zLn = P("ln");
17491750
17501751
if( P("ci") && P("filename") ){
17511752
rid = artifact_from_ci_and_filename_www();
17521753
}
17531754
if( rid==0 ){
@@ -1811,10 +1812,13 @@
18111812
style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid);
18121813
}
18131814
if( descOnly ){
18141815
style_submenu_element("Content", "Content", "%R/artifact/%s", zUuid);
18151816
}else{
1817
+ style_submenu_element("Line Numbers", "Line Numbers",
1818
+ "%R/info/%s%s",zUuid,
1819
+ ((zLn&&*zLn) ? "" : "?ln=0"));
18161820
@ <hr />
18171821
content_get(rid, &content);
18181822
if( renderAsWiki ){
18191823
wiki_render_by_mimetype(&content, zMime);
18201824
}else if( renderAsHtml ){
@@ -1827,11 +1831,10 @@
18271831
style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
18281832
blob_to_utf8_no_bom(&content, 0);
18291833
zMime = mimetype_from_content(&content);
18301834
@ <blockquote>
18311835
if( zMime==0 ){
1832
- const char *zLn = P("ln");
18331836
const char *z;
18341837
z = blob_str(&content);
18351838
if( zLn ){
18361839
output_text_with_line_numbers(z, zLn);
18371840
}else{
18381841
--- 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

Keyboard Shortcuts

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