Fossil SCM
Use the abbreviated object description by default. But provide a hyperlink to a detailed description (using the new /whatis web page) if details are omitted.
Commit
3c2d418b600a81d7234335063c8d5b8fc0f59d26
Parent
0ac4cead8d55805…
1 file changed
+70
-55
+70
-55
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1116,11 +1116,11 @@ | ||
| 1116 | 1116 | |
| 1117 | 1117 | /* |
| 1118 | 1118 | ** Possible flags for the second parameter to |
| 1119 | 1119 | ** object_description() |
| 1120 | 1120 | */ |
| 1121 | -#define OBJDESC_BRIEF 0x0001 /* Less detail */ | |
| 1121 | +#define OBJDESC_DETAIL 0x0001 /* more detail */ | |
| 1122 | 1122 | #endif |
| 1123 | 1123 | |
| 1124 | 1124 | /* |
| 1125 | 1125 | ** Write a description of an object to the www reply. |
| 1126 | 1126 | ** |
| @@ -1144,11 +1144,11 @@ | ||
| 1144 | 1144 | Stmt q; |
| 1145 | 1145 | int cnt = 0; |
| 1146 | 1146 | int nWiki = 0; |
| 1147 | 1147 | int objType = 0; |
| 1148 | 1148 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1149 | - int isBrief = (objdescFlags & OBJDESC_BRIEF)!=0; | |
| 1149 | + int showDetail = (objdescFlags & OBJDESC_DETAIL)!=0; | |
| 1150 | 1150 | char *prevName = 0; |
| 1151 | 1151 | |
| 1152 | 1152 | db_prepare(&q, |
| 1153 | 1153 | "SELECT filename.name, datetime(event.mtime)," |
| 1154 | 1154 | " coalesce(event.ecomment,event.comment)," |
| @@ -1173,11 +1173,17 @@ | ||
| 1173 | 1173 | const char *zUser = db_column_text(&q, 3); |
| 1174 | 1174 | const char *zVers = db_column_text(&q, 4); |
| 1175 | 1175 | int mPerm = db_column_int(&q, 5); |
| 1176 | 1176 | const char *zBr = db_column_text(&q, 6); |
| 1177 | 1177 | int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0; |
| 1178 | - if( sameFilename && isBrief ) continue; | |
| 1178 | + if( sameFilename && !showDetail ){ | |
| 1179 | + if( cnt==1 ){ | |
| 1180 | + @ %z(href("%R/whatis/%s",zUuid))[more...]</a> | |
| 1181 | + } | |
| 1182 | + cnt++; | |
| 1183 | + continue; | |
| 1184 | + } | |
| 1179 | 1185 | if( !sameFilename ){ |
| 1180 | 1186 | if( prevName ) { |
| 1181 | 1187 | @ </ul> |
| 1182 | 1188 | } |
| 1183 | 1189 | if( mPerm==PERM_LNK ){ |
| @@ -1189,25 +1195,25 @@ | ||
| 1189 | 1195 | }else{ |
| 1190 | 1196 | @ <li>File |
| 1191 | 1197 | } |
| 1192 | 1198 | objType |= OBJTYPE_CONTENT; |
| 1193 | 1199 | @ %z(href("%R/finfo?name=%T",zName))%h(zName)</a> |
| 1194 | - if( !isBrief ){ | |
| 1200 | + if( showDetail ){ | |
| 1195 | 1201 | @ <ul> |
| 1196 | 1202 | } |
| 1197 | 1203 | prevName = fossil_strdup(zName); |
| 1198 | 1204 | } |
| 1199 | - if( isBrief ){ | |
| 1200 | - @ — from checkin | |
| 1201 | - hyperlink_to_uuid(zVers); | |
| 1202 | - @ at | |
| 1203 | - hyperlink_to_date(zDate,""); | |
| 1204 | - }else{ | |
| 1205 | + if( showDetail ){ | |
| 1205 | 1206 | @ <li> |
| 1206 | 1207 | hyperlink_to_date(zDate,""); |
| 1207 | 1208 | @ — part of check-in |
| 1208 | 1209 | hyperlink_to_uuid(zVers); |
| 1210 | + }else{ | |
| 1211 | + @ — part of checkin | |
| 1212 | + hyperlink_to_uuid(zVers); | |
| 1213 | + @ at | |
| 1214 | + hyperlink_to_date(zDate,""); | |
| 1209 | 1215 | } |
| 1210 | 1216 | if( zBr && zBr[0] ){ |
| 1211 | 1217 | @ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a> |
| 1212 | 1218 | } |
| 1213 | 1219 | @ — %!w(zCom) (user: |
| @@ -1222,11 +1228,11 @@ | ||
| 1222 | 1228 | cnt++; |
| 1223 | 1229 | if( pDownloadName && blob_size(pDownloadName)==0 ){ |
| 1224 | 1230 | blob_append(pDownloadName, zName, -1); |
| 1225 | 1231 | } |
| 1226 | 1232 | } |
| 1227 | - if( prevName && !isBrief ){ | |
| 1233 | + if( prevName && showDetail ){ | |
| 1228 | 1234 | @ </ul> |
| 1229 | 1235 | } |
| 1230 | 1236 | @ </ul> |
| 1231 | 1237 | free(prevName); |
| 1232 | 1238 | db_finalize(&q); |
| @@ -1365,11 +1371,11 @@ | ||
| 1365 | 1371 | ** difference between the two artifacts. Show diff side by side unless sbs |
| 1366 | 1372 | ** is 0. Generate plaintext if "patch" is present. |
| 1367 | 1373 | ** |
| 1368 | 1374 | ** Additional parameters: |
| 1369 | 1375 | ** |
| 1370 | -** brief Show less detail when describing artifacts | |
| 1376 | +** verbose Show more detail when describing artifacts | |
| 1371 | 1377 | */ |
| 1372 | 1378 | void diff_page(void){ |
| 1373 | 1379 | int v1, v2; |
| 1374 | 1380 | int isPatch; |
| 1375 | 1381 | int sideBySide; |
| @@ -1386,11 +1392,11 @@ | ||
| 1386 | 1392 | v1 = name_to_rid_www("v1"); |
| 1387 | 1393 | v2 = name_to_rid_www("v2"); |
| 1388 | 1394 | if( v1==0 || v2==0 ) fossil_redirect_home(); |
| 1389 | 1395 | zRe = P("regex"); |
| 1390 | 1396 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 1391 | - if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; | |
| 1397 | + if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; | |
| 1392 | 1398 | isPatch = P("patch")!=0; |
| 1393 | 1399 | if( isPatch ){ |
| 1394 | 1400 | Blob c1, c2, *pOut; |
| 1395 | 1401 | pOut = cgi_output_blob(); |
| 1396 | 1402 | cgi_set_content_type("text/plain"); |
| @@ -1551,11 +1557,11 @@ | ||
| 1551 | 1557 | ** Show the complete content of a file identified by ARTIFACTID |
| 1552 | 1558 | ** as preformatted text. |
| 1553 | 1559 | ** |
| 1554 | 1560 | ** Other parameters: |
| 1555 | 1561 | ** |
| 1556 | -** brief Show less detail when describing the object | |
| 1562 | +** verbose Show more detail when describing the object | |
| 1557 | 1563 | */ |
| 1558 | 1564 | void hexdump_page(void){ |
| 1559 | 1565 | int rid; |
| 1560 | 1566 | Blob content; |
| 1561 | 1567 | Blob downloadName; |
| @@ -1582,11 +1588,11 @@ | ||
| 1582 | 1588 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1583 | 1589 | }else{ |
| 1584 | 1590 | @ <h2>Artifact %s(zUuid):</h2> |
| 1585 | 1591 | } |
| 1586 | 1592 | blob_zero(&downloadName); |
| 1587 | - if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; | |
| 1593 | + if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; | |
| 1588 | 1594 | object_description(rid, objdescFlags, &downloadName); |
| 1589 | 1595 | style_submenu_element("Download", "Download", |
| 1590 | 1596 | "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid); |
| 1591 | 1597 | @ <hr /> |
| 1592 | 1598 | content_get(rid, &content); |
| @@ -1708,23 +1714,27 @@ | ||
| 1708 | 1714 | } |
| 1709 | 1715 | } |
| 1710 | 1716 | |
| 1711 | 1717 | |
| 1712 | 1718 | /* |
| 1719 | +** WEBPAGE: whatis | |
| 1713 | 1720 | ** WEBPAGE: artifact |
| 1714 | -** URL: /artifact/ARTIFACTID | |
| 1721 | +** | |
| 1722 | +** URL: /artifact/SHA1HASH | |
| 1715 | 1723 | ** URL: /artifact?ci=CHECKIN&filename=PATH |
| 1724 | +** URL: /whatis/SHA1HASH | |
| 1716 | 1725 | ** |
| 1717 | 1726 | ** Additional query parameters: |
| 1718 | 1727 | ** |
| 1719 | 1728 | ** ln - show line numbers |
| 1720 | 1729 | ** ln=N - highlight line number N |
| 1721 | 1730 | ** ln=M-N - highlight lines M through N inclusive |
| 1722 | -** brief - show less detail in the description | |
| 1731 | +** verbose - show more detail in the description | |
| 1723 | 1732 | ** |
| 1724 | -** Show the complete content of a file identified by ARTIFACTID | |
| 1725 | -** as preformatted text. | |
| 1733 | +** The /artifact page show the complete content of a file | |
| 1734 | +** identified by SHA1HASH as preformatted text. The | |
| 1735 | +** /whatis page shows only a description of the file. | |
| 1726 | 1736 | */ |
| 1727 | 1737 | void artifact_page(void){ |
| 1728 | 1738 | int rid = 0; |
| 1729 | 1739 | Blob content; |
| 1730 | 1740 | const char *zMime; |
| @@ -1733,10 +1743,11 @@ | ||
| 1733 | 1743 | int renderAsHtml = 0; |
| 1734 | 1744 | int objType; |
| 1735 | 1745 | int asText; |
| 1736 | 1746 | const char *zUuid; |
| 1737 | 1747 | u32 objdescFlags = 0; |
| 1748 | + int descOnly = fossil_strcmp(g.zPath,"whatis")==0; | |
| 1738 | 1749 | |
| 1739 | 1750 | if( P("ci") && P("filename") ){ |
| 1740 | 1751 | rid = artifact_from_ci_and_filename_www(); |
| 1741 | 1752 | } |
| 1742 | 1753 | if( rid==0 ){ |
| @@ -1754,12 +1765,12 @@ | ||
| 1754 | 1765 | }else{ |
| 1755 | 1766 | style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun", |
| 1756 | 1767 | g.zTop, zUuid); |
| 1757 | 1768 | } |
| 1758 | 1769 | } |
| 1759 | - if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; | |
| 1760 | - style_header("Artifact Content"); | |
| 1770 | + if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; | |
| 1771 | + style_header(descOnly ? "Artifact Description" : "Artifact Content"); | |
| 1761 | 1772 | zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1762 | 1773 | if( g.perm.Setup ){ |
| 1763 | 1774 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1764 | 1775 | }else{ |
| 1765 | 1776 | @ <h2>Artifact %s(zUuid):</h2> |
| @@ -1797,44 +1808,48 @@ | ||
| 1797 | 1808 | } |
| 1798 | 1809 | } |
| 1799 | 1810 | if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){ |
| 1800 | 1811 | style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid); |
| 1801 | 1812 | } |
| 1802 | - @ <hr /> | |
| 1803 | - content_get(rid, &content); | |
| 1804 | - if( renderAsWiki ){ | |
| 1805 | - wiki_render_by_mimetype(&content, zMime); | |
| 1806 | - }else if( renderAsHtml ){ | |
| 1807 | - @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)" | |
| 1808 | - @ width="100%%" frameborder="0" marginwidth="0" marginheight="0" | |
| 1809 | - @ sandbox="allow-same-origin" | |
| 1810 | - @ onload="this.height = this.contentDocument.documentElement.scrollHeight;"> | |
| 1811 | - @ </iframe> | |
| 1812 | - }else{ | |
| 1813 | - style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid); | |
| 1814 | - blob_to_utf8_no_bom(&content, 0); | |
| 1815 | - zMime = mimetype_from_content(&content); | |
| 1816 | - @ <blockquote> | |
| 1817 | - if( zMime==0 ){ | |
| 1818 | - const char *zLn = P("ln"); | |
| 1819 | - const char *z; | |
| 1820 | - z = blob_str(&content); | |
| 1821 | - if( zLn ){ | |
| 1822 | - output_text_with_line_numbers(z, zLn); | |
| 1823 | - }else{ | |
| 1824 | - @ <pre> | |
| 1825 | - @ %h(z) | |
| 1826 | - @ </pre> | |
| 1827 | - } | |
| 1828 | - }else if( strncmp(zMime, "image/", 6)==0 ){ | |
| 1829 | - @ <img src="%R/raw/%s(zUuid)?m=%s(zMime)" /> | |
| 1830 | - style_submenu_element("Image", "Image", | |
| 1831 | - "%R/raw/%s?m=%s", zUuid, zMime); | |
| 1832 | - }else{ | |
| 1833 | - @ <i>(file is %d(blob_size(&content)) bytes of binary data)</i> | |
| 1834 | - } | |
| 1835 | - @ </blockquote> | |
| 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 ){ | |
| 1821 | + @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)" | |
| 1822 | + @ width="100%%" frameborder="0" marginwidth="0" marginheight="0" | |
| 1823 | + @ sandbox="allow-same-origin" | |
| 1824 | + @ onload="this.height = this.contentDocument.documentElement.scrollHeight;"> | |
| 1825 | + @ </iframe> | |
| 1826 | + }else{ | |
| 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 | + @ <pre> | |
| 1839 | + @ %h(z) | |
| 1840 | + @ </pre> | |
| 1841 | + } | |
| 1842 | + }else if( strncmp(zMime, "image/", 6)==0 ){ | |
| 1843 | + @ <img src="%R/raw/%s(zUuid)?m=%s(zMime)" /> | |
| 1844 | + style_submenu_element("Image", "Image", | |
| 1845 | + "%R/raw/%s?m=%s", zUuid, zMime); | |
| 1846 | + }else{ | |
| 1847 | + @ <i>(file is %d(blob_size(&content)) bytes of binary data)</i> | |
| 1848 | + } | |
| 1849 | + @ </blockquote> | |
| 1850 | + } | |
| 1836 | 1851 | } |
| 1837 | 1852 | style_footer(); |
| 1838 | 1853 | } |
| 1839 | 1854 | |
| 1840 | 1855 | /* |
| 1841 | 1856 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1116,11 +1116,11 @@ | |
| 1116 | |
| 1117 | /* |
| 1118 | ** Possible flags for the second parameter to |
| 1119 | ** object_description() |
| 1120 | */ |
| 1121 | #define OBJDESC_BRIEF 0x0001 /* Less detail */ |
| 1122 | #endif |
| 1123 | |
| 1124 | /* |
| 1125 | ** Write a description of an object to the www reply. |
| 1126 | ** |
| @@ -1144,11 +1144,11 @@ | |
| 1144 | Stmt q; |
| 1145 | int cnt = 0; |
| 1146 | int nWiki = 0; |
| 1147 | int objType = 0; |
| 1148 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1149 | int isBrief = (objdescFlags & OBJDESC_BRIEF)!=0; |
| 1150 | char *prevName = 0; |
| 1151 | |
| 1152 | db_prepare(&q, |
| 1153 | "SELECT filename.name, datetime(event.mtime)," |
| 1154 | " coalesce(event.ecomment,event.comment)," |
| @@ -1173,11 +1173,17 @@ | |
| 1173 | const char *zUser = db_column_text(&q, 3); |
| 1174 | const char *zVers = db_column_text(&q, 4); |
| 1175 | int mPerm = db_column_int(&q, 5); |
| 1176 | const char *zBr = db_column_text(&q, 6); |
| 1177 | int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0; |
| 1178 | if( sameFilename && isBrief ) continue; |
| 1179 | if( !sameFilename ){ |
| 1180 | if( prevName ) { |
| 1181 | @ </ul> |
| 1182 | } |
| 1183 | if( mPerm==PERM_LNK ){ |
| @@ -1189,25 +1195,25 @@ | |
| 1189 | }else{ |
| 1190 | @ <li>File |
| 1191 | } |
| 1192 | objType |= OBJTYPE_CONTENT; |
| 1193 | @ %z(href("%R/finfo?name=%T",zName))%h(zName)</a> |
| 1194 | if( !isBrief ){ |
| 1195 | @ <ul> |
| 1196 | } |
| 1197 | prevName = fossil_strdup(zName); |
| 1198 | } |
| 1199 | if( isBrief ){ |
| 1200 | @ — from checkin |
| 1201 | hyperlink_to_uuid(zVers); |
| 1202 | @ at |
| 1203 | hyperlink_to_date(zDate,""); |
| 1204 | }else{ |
| 1205 | @ <li> |
| 1206 | hyperlink_to_date(zDate,""); |
| 1207 | @ — part of check-in |
| 1208 | hyperlink_to_uuid(zVers); |
| 1209 | } |
| 1210 | if( zBr && zBr[0] ){ |
| 1211 | @ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a> |
| 1212 | } |
| 1213 | @ — %!w(zCom) (user: |
| @@ -1222,11 +1228,11 @@ | |
| 1222 | cnt++; |
| 1223 | if( pDownloadName && blob_size(pDownloadName)==0 ){ |
| 1224 | blob_append(pDownloadName, zName, -1); |
| 1225 | } |
| 1226 | } |
| 1227 | if( prevName && !isBrief ){ |
| 1228 | @ </ul> |
| 1229 | } |
| 1230 | @ </ul> |
| 1231 | free(prevName); |
| 1232 | db_finalize(&q); |
| @@ -1365,11 +1371,11 @@ | |
| 1365 | ** difference between the two artifacts. Show diff side by side unless sbs |
| 1366 | ** is 0. Generate plaintext if "patch" is present. |
| 1367 | ** |
| 1368 | ** Additional parameters: |
| 1369 | ** |
| 1370 | ** brief Show less detail when describing artifacts |
| 1371 | */ |
| 1372 | void diff_page(void){ |
| 1373 | int v1, v2; |
| 1374 | int isPatch; |
| 1375 | int sideBySide; |
| @@ -1386,11 +1392,11 @@ | |
| 1386 | v1 = name_to_rid_www("v1"); |
| 1387 | v2 = name_to_rid_www("v2"); |
| 1388 | if( v1==0 || v2==0 ) fossil_redirect_home(); |
| 1389 | zRe = P("regex"); |
| 1390 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 1391 | if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; |
| 1392 | isPatch = P("patch")!=0; |
| 1393 | if( isPatch ){ |
| 1394 | Blob c1, c2, *pOut; |
| 1395 | pOut = cgi_output_blob(); |
| 1396 | cgi_set_content_type("text/plain"); |
| @@ -1551,11 +1557,11 @@ | |
| 1551 | ** Show the complete content of a file identified by ARTIFACTID |
| 1552 | ** as preformatted text. |
| 1553 | ** |
| 1554 | ** Other parameters: |
| 1555 | ** |
| 1556 | ** brief Show less detail when describing the object |
| 1557 | */ |
| 1558 | void hexdump_page(void){ |
| 1559 | int rid; |
| 1560 | Blob content; |
| 1561 | Blob downloadName; |
| @@ -1582,11 +1588,11 @@ | |
| 1582 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1583 | }else{ |
| 1584 | @ <h2>Artifact %s(zUuid):</h2> |
| 1585 | } |
| 1586 | blob_zero(&downloadName); |
| 1587 | if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; |
| 1588 | object_description(rid, objdescFlags, &downloadName); |
| 1589 | style_submenu_element("Download", "Download", |
| 1590 | "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid); |
| 1591 | @ <hr /> |
| 1592 | content_get(rid, &content); |
| @@ -1708,23 +1714,27 @@ | |
| 1708 | } |
| 1709 | } |
| 1710 | |
| 1711 | |
| 1712 | /* |
| 1713 | ** WEBPAGE: artifact |
| 1714 | ** URL: /artifact/ARTIFACTID |
| 1715 | ** URL: /artifact?ci=CHECKIN&filename=PATH |
| 1716 | ** |
| 1717 | ** Additional query parameters: |
| 1718 | ** |
| 1719 | ** ln - show line numbers |
| 1720 | ** ln=N - highlight line number N |
| 1721 | ** ln=M-N - highlight lines M through N inclusive |
| 1722 | ** brief - show less detail in the description |
| 1723 | ** |
| 1724 | ** Show the complete content of a file identified by ARTIFACTID |
| 1725 | ** as preformatted text. |
| 1726 | */ |
| 1727 | void artifact_page(void){ |
| 1728 | int rid = 0; |
| 1729 | Blob content; |
| 1730 | const char *zMime; |
| @@ -1733,10 +1743,11 @@ | |
| 1733 | int renderAsHtml = 0; |
| 1734 | int objType; |
| 1735 | int asText; |
| 1736 | const char *zUuid; |
| 1737 | u32 objdescFlags = 0; |
| 1738 | |
| 1739 | if( P("ci") && P("filename") ){ |
| 1740 | rid = artifact_from_ci_and_filename_www(); |
| 1741 | } |
| 1742 | if( rid==0 ){ |
| @@ -1754,12 +1765,12 @@ | |
| 1754 | }else{ |
| 1755 | style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun", |
| 1756 | g.zTop, zUuid); |
| 1757 | } |
| 1758 | } |
| 1759 | if( P("brief")!=0 ) objdescFlags |= OBJDESC_BRIEF; |
| 1760 | style_header("Artifact Content"); |
| 1761 | zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1762 | if( g.perm.Setup ){ |
| 1763 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1764 | }else{ |
| 1765 | @ <h2>Artifact %s(zUuid):</h2> |
| @@ -1797,44 +1808,48 @@ | |
| 1797 | } |
| 1798 | } |
| 1799 | if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){ |
| 1800 | style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid); |
| 1801 | } |
| 1802 | @ <hr /> |
| 1803 | content_get(rid, &content); |
| 1804 | if( renderAsWiki ){ |
| 1805 | wiki_render_by_mimetype(&content, zMime); |
| 1806 | }else if( renderAsHtml ){ |
| 1807 | @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)" |
| 1808 | @ width="100%%" frameborder="0" marginwidth="0" marginheight="0" |
| 1809 | @ sandbox="allow-same-origin" |
| 1810 | @ onload="this.height = this.contentDocument.documentElement.scrollHeight;"> |
| 1811 | @ </iframe> |
| 1812 | }else{ |
| 1813 | style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid); |
| 1814 | blob_to_utf8_no_bom(&content, 0); |
| 1815 | zMime = mimetype_from_content(&content); |
| 1816 | @ <blockquote> |
| 1817 | if( zMime==0 ){ |
| 1818 | const char *zLn = P("ln"); |
| 1819 | const char *z; |
| 1820 | z = blob_str(&content); |
| 1821 | if( zLn ){ |
| 1822 | output_text_with_line_numbers(z, zLn); |
| 1823 | }else{ |
| 1824 | @ <pre> |
| 1825 | @ %h(z) |
| 1826 | @ </pre> |
| 1827 | } |
| 1828 | }else if( strncmp(zMime, "image/", 6)==0 ){ |
| 1829 | @ <img src="%R/raw/%s(zUuid)?m=%s(zMime)" /> |
| 1830 | style_submenu_element("Image", "Image", |
| 1831 | "%R/raw/%s?m=%s", zUuid, zMime); |
| 1832 | }else{ |
| 1833 | @ <i>(file is %d(blob_size(&content)) bytes of binary data)</i> |
| 1834 | } |
| 1835 | @ </blockquote> |
| 1836 | } |
| 1837 | style_footer(); |
| 1838 | } |
| 1839 | |
| 1840 | /* |
| 1841 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1116,11 +1116,11 @@ | |
| 1116 | |
| 1117 | /* |
| 1118 | ** Possible flags for the second parameter to |
| 1119 | ** object_description() |
| 1120 | */ |
| 1121 | #define OBJDESC_DETAIL 0x0001 /* more detail */ |
| 1122 | #endif |
| 1123 | |
| 1124 | /* |
| 1125 | ** Write a description of an object to the www reply. |
| 1126 | ** |
| @@ -1144,11 +1144,11 @@ | |
| 1144 | Stmt q; |
| 1145 | int cnt = 0; |
| 1146 | int nWiki = 0; |
| 1147 | int objType = 0; |
| 1148 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1149 | int showDetail = (objdescFlags & OBJDESC_DETAIL)!=0; |
| 1150 | char *prevName = 0; |
| 1151 | |
| 1152 | db_prepare(&q, |
| 1153 | "SELECT filename.name, datetime(event.mtime)," |
| 1154 | " coalesce(event.ecomment,event.comment)," |
| @@ -1173,11 +1173,17 @@ | |
| 1173 | const char *zUser = db_column_text(&q, 3); |
| 1174 | const char *zVers = db_column_text(&q, 4); |
| 1175 | int mPerm = db_column_int(&q, 5); |
| 1176 | const char *zBr = db_column_text(&q, 6); |
| 1177 | int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0; |
| 1178 | if( sameFilename && !showDetail ){ |
| 1179 | if( cnt==1 ){ |
| 1180 | @ %z(href("%R/whatis/%s",zUuid))[more...]</a> |
| 1181 | } |
| 1182 | cnt++; |
| 1183 | continue; |
| 1184 | } |
| 1185 | if( !sameFilename ){ |
| 1186 | if( prevName ) { |
| 1187 | @ </ul> |
| 1188 | } |
| 1189 | if( mPerm==PERM_LNK ){ |
| @@ -1189,25 +1195,25 @@ | |
| 1195 | }else{ |
| 1196 | @ <li>File |
| 1197 | } |
| 1198 | objType |= OBJTYPE_CONTENT; |
| 1199 | @ %z(href("%R/finfo?name=%T",zName))%h(zName)</a> |
| 1200 | if( showDetail ){ |
| 1201 | @ <ul> |
| 1202 | } |
| 1203 | prevName = fossil_strdup(zName); |
| 1204 | } |
| 1205 | if( showDetail ){ |
| 1206 | @ <li> |
| 1207 | hyperlink_to_date(zDate,""); |
| 1208 | @ — part of check-in |
| 1209 | hyperlink_to_uuid(zVers); |
| 1210 | }else{ |
| 1211 | @ — part of checkin |
| 1212 | hyperlink_to_uuid(zVers); |
| 1213 | @ at |
| 1214 | hyperlink_to_date(zDate,""); |
| 1215 | } |
| 1216 | if( zBr && zBr[0] ){ |
| 1217 | @ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a> |
| 1218 | } |
| 1219 | @ — %!w(zCom) (user: |
| @@ -1222,11 +1228,11 @@ | |
| 1228 | cnt++; |
| 1229 | if( pDownloadName && blob_size(pDownloadName)==0 ){ |
| 1230 | blob_append(pDownloadName, zName, -1); |
| 1231 | } |
| 1232 | } |
| 1233 | if( prevName && showDetail ){ |
| 1234 | @ </ul> |
| 1235 | } |
| 1236 | @ </ul> |
| 1237 | free(prevName); |
| 1238 | db_finalize(&q); |
| @@ -1365,11 +1371,11 @@ | |
| 1371 | ** difference between the two artifacts. Show diff side by side unless sbs |
| 1372 | ** is 0. Generate plaintext if "patch" is present. |
| 1373 | ** |
| 1374 | ** Additional parameters: |
| 1375 | ** |
| 1376 | ** verbose Show more detail when describing artifacts |
| 1377 | */ |
| 1378 | void diff_page(void){ |
| 1379 | int v1, v2; |
| 1380 | int isPatch; |
| 1381 | int sideBySide; |
| @@ -1386,11 +1392,11 @@ | |
| 1392 | v1 = name_to_rid_www("v1"); |
| 1393 | v2 = name_to_rid_www("v2"); |
| 1394 | if( v1==0 || v2==0 ) fossil_redirect_home(); |
| 1395 | zRe = P("regex"); |
| 1396 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 1397 | if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; |
| 1398 | isPatch = P("patch")!=0; |
| 1399 | if( isPatch ){ |
| 1400 | Blob c1, c2, *pOut; |
| 1401 | pOut = cgi_output_blob(); |
| 1402 | cgi_set_content_type("text/plain"); |
| @@ -1551,11 +1557,11 @@ | |
| 1557 | ** Show the complete content of a file identified by ARTIFACTID |
| 1558 | ** as preformatted text. |
| 1559 | ** |
| 1560 | ** Other parameters: |
| 1561 | ** |
| 1562 | ** verbose Show more detail when describing the object |
| 1563 | */ |
| 1564 | void hexdump_page(void){ |
| 1565 | int rid; |
| 1566 | Blob content; |
| 1567 | Blob downloadName; |
| @@ -1582,11 +1588,11 @@ | |
| 1588 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1589 | }else{ |
| 1590 | @ <h2>Artifact %s(zUuid):</h2> |
| 1591 | } |
| 1592 | blob_zero(&downloadName); |
| 1593 | if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; |
| 1594 | object_description(rid, objdescFlags, &downloadName); |
| 1595 | style_submenu_element("Download", "Download", |
| 1596 | "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid); |
| 1597 | @ <hr /> |
| 1598 | content_get(rid, &content); |
| @@ -1708,23 +1714,27 @@ | |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | |
| 1718 | /* |
| 1719 | ** WEBPAGE: whatis |
| 1720 | ** WEBPAGE: artifact |
| 1721 | ** |
| 1722 | ** URL: /artifact/SHA1HASH |
| 1723 | ** URL: /artifact?ci=CHECKIN&filename=PATH |
| 1724 | ** URL: /whatis/SHA1HASH |
| 1725 | ** |
| 1726 | ** Additional query parameters: |
| 1727 | ** |
| 1728 | ** ln - show line numbers |
| 1729 | ** ln=N - highlight line number N |
| 1730 | ** ln=M-N - highlight lines M through N inclusive |
| 1731 | ** verbose - show more detail in the description |
| 1732 | ** |
| 1733 | ** The /artifact page show the complete content of a file |
| 1734 | ** identified by SHA1HASH as preformatted text. The |
| 1735 | ** /whatis page shows only a description of the file. |
| 1736 | */ |
| 1737 | void artifact_page(void){ |
| 1738 | int rid = 0; |
| 1739 | Blob content; |
| 1740 | const char *zMime; |
| @@ -1733,10 +1743,11 @@ | |
| 1743 | int renderAsHtml = 0; |
| 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 ){ |
| @@ -1754,12 +1765,12 @@ | |
| 1765 | }else{ |
| 1766 | style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun", |
| 1767 | g.zTop, zUuid); |
| 1768 | } |
| 1769 | } |
| 1770 | if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; |
| 1771 | style_header(descOnly ? "Artifact Description" : "Artifact Content"); |
| 1772 | zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1773 | if( g.perm.Setup ){ |
| 1774 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1775 | }else{ |
| 1776 | @ <h2>Artifact %s(zUuid):</h2> |
| @@ -1797,44 +1808,48 @@ | |
| 1808 | } |
| 1809 | } |
| 1810 | if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){ |
| 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 ){ |
| 1821 | @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)" |
| 1822 | @ width="100%%" frameborder="0" marginwidth="0" marginheight="0" |
| 1823 | @ sandbox="allow-same-origin" |
| 1824 | @ onload="this.height = this.contentDocument.documentElement.scrollHeight;"> |
| 1825 | @ </iframe> |
| 1826 | }else{ |
| 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 | @ <pre> |
| 1839 | @ %h(z) |
| 1840 | @ </pre> |
| 1841 | } |
| 1842 | }else if( strncmp(zMime, "image/", 6)==0 ){ |
| 1843 | @ <img src="%R/raw/%s(zUuid)?m=%s(zMime)" /> |
| 1844 | style_submenu_element("Image", "Image", |
| 1845 | "%R/raw/%s?m=%s", zUuid, zMime); |
| 1846 | }else{ |
| 1847 | @ <i>(file is %d(blob_size(&content)) bytes of binary data)</i> |
| 1848 | } |
| 1849 | @ </blockquote> |
| 1850 | } |
| 1851 | } |
| 1852 | style_footer(); |
| 1853 | } |
| 1854 | |
| 1855 | /* |
| 1856 |