Fossil SCM
Add infrastructure for making some hyperlinks have class='inlinebutton'. But there does not appear to be a good way to style this, so the change is abandoned.
Commit
6535398e879420cedcbca5a22d4c600d02d3dab6
Parent
d539f65cc2d2a09…
2 files changed
+40
-28
+1
-1
+40
-28
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -115,53 +115,65 @@ | ||
| 115 | 115 | ** |
| 116 | 116 | ** Note %z format. The string returned by this function is always |
| 117 | 117 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 118 | 118 | ** that memory space. |
| 119 | 119 | ** |
| 120 | -** There are two versions of this routine: href() does a plain hyperlink | |
| 121 | -** and xhref() adds extra attribute text. | |
| 120 | +** There are three versions of this routine: href() does a plain hyperlink | |
| 121 | +** and xhref() adds extra attribute text. The btn() version adds a | |
| 122 | +** single "class='inlinebutton'" class to the anchor. | |
| 122 | 123 | ** |
| 123 | 124 | ** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. |
| 124 | 125 | ** Most logged in users should have this property, since we can assume |
| 125 | 126 | ** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, |
| 126 | 127 | ** typically. |
| 127 | 128 | */ |
| 128 | -char *xhref(const char *zExtra, const char *zFormat, ...){ | |
| 129 | +char *vxhref(const char *zExtra, const char *zFormat, va_list ap){ | |
| 129 | 130 | char *zUrl; |
| 131 | + Blob ref = empty_blob; | |
| 132 | + blob_append(&ref, "<a ", 3); | |
| 133 | + if( zExtra ){ | |
| 134 | + blob_append(&ref, zExtra, -1); | |
| 135 | + blob_append(&ref, " ", 1); | |
| 136 | + } | |
| 137 | + zUrl = vmprintf(zFormat, ap); | |
| 138 | + if( g.perm.Hyperlink && !g.javascriptHyperlink ){ | |
| 139 | + blob_appendf(&ref,"href='%h'>", zUrl); | |
| 140 | + fossil_free(zUrl); | |
| 141 | + }else{ | |
| 142 | + if( nHref>=nHrefAlloc ){ | |
| 143 | + nHrefAlloc = nHrefAlloc*2 + 10; | |
| 144 | + aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); | |
| 145 | + } | |
| 146 | + aHref[nHref++] = zUrl; | |
| 147 | + blob_appendf(&ref, "id='a%d' href='%R/honeypot'>", nHref); | |
| 148 | + } | |
| 149 | + blob_materialize(&ref); | |
| 150 | + return ref.aData; | |
| 151 | +} | |
| 152 | +char *xhref(const char *zExtra, const char *zFormat, ...){ | |
| 153 | + char *zResult; | |
| 130 | 154 | va_list ap; |
| 131 | 155 | va_start(ap, zFormat); |
| 132 | - zUrl = vmprintf(zFormat, ap); | |
| 156 | + zResult = vxhref(zExtra, zFormat, ap); | |
| 133 | 157 | va_end(ap); |
| 134 | - if( g.perm.Hyperlink && !g.javascriptHyperlink ){ | |
| 135 | - char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl); | |
| 136 | - fossil_free(zUrl); | |
| 137 | - return zHUrl; | |
| 138 | - } | |
| 139 | - if( nHref>=nHrefAlloc ){ | |
| 140 | - nHrefAlloc = nHrefAlloc*2 + 10; | |
| 141 | - aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); | |
| 142 | - } | |
| 143 | - aHref[nHref++] = zUrl; | |
| 144 | - return mprintf("<a %s id='a%d' href='%R/honeypot'>", zExtra, nHref); | |
| 158 | + return zResult; | |
| 145 | 159 | } |
| 146 | 160 | char *href(const char *zFormat, ...){ |
| 147 | - char *zUrl; | |
| 161 | + char *zResult; | |
| 162 | + va_list ap; | |
| 163 | + va_start(ap, zFormat); | |
| 164 | + zResult = vxhref(0, zFormat, ap); | |
| 165 | + va_end(ap); | |
| 166 | + return zResult; | |
| 167 | +} | |
| 168 | +char *btn(const char *zFormat, ...){ | |
| 169 | + char *zResult; | |
| 148 | 170 | va_list ap; |
| 149 | 171 | va_start(ap, zFormat); |
| 150 | - zUrl = vmprintf(zFormat, ap); | |
| 172 | + zResult = vxhref("class='inlinebutton'", zFormat, ap); | |
| 151 | 173 | va_end(ap); |
| 152 | - if( g.perm.Hyperlink && !g.javascriptHyperlink ){ | |
| 153 | - char *zHUrl = mprintf("<a href=\"%h\">", zUrl); | |
| 154 | - fossil_free(zUrl); | |
| 155 | - return zHUrl; | |
| 156 | - } | |
| 157 | - if( nHref>=nHrefAlloc ){ | |
| 158 | - nHrefAlloc = nHrefAlloc*2 + 10; | |
| 159 | - aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); | |
| 160 | - } | |
| 161 | - aHref[nHref++] = zUrl; | |
| 162 | - return mprintf("<a id='a%d' href='%R/honeypot'>", nHref); | |
| 174 | + return zResult; | |
| 163 | 175 | } |
| 164 | 176 | |
| 165 | 177 | /* |
| 166 | 178 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 167 | 179 | ** by javascript. |
| 168 | 180 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -115,53 +115,65 @@ | |
| 115 | ** |
| 116 | ** Note %z format. The string returned by this function is always |
| 117 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 118 | ** that memory space. |
| 119 | ** |
| 120 | ** There are two versions of this routine: href() does a plain hyperlink |
| 121 | ** and xhref() adds extra attribute text. |
| 122 | ** |
| 123 | ** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. |
| 124 | ** Most logged in users should have this property, since we can assume |
| 125 | ** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, |
| 126 | ** typically. |
| 127 | */ |
| 128 | char *xhref(const char *zExtra, const char *zFormat, ...){ |
| 129 | char *zUrl; |
| 130 | va_list ap; |
| 131 | va_start(ap, zFormat); |
| 132 | zUrl = vmprintf(zFormat, ap); |
| 133 | va_end(ap); |
| 134 | if( g.perm.Hyperlink && !g.javascriptHyperlink ){ |
| 135 | char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl); |
| 136 | fossil_free(zUrl); |
| 137 | return zHUrl; |
| 138 | } |
| 139 | if( nHref>=nHrefAlloc ){ |
| 140 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 141 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 142 | } |
| 143 | aHref[nHref++] = zUrl; |
| 144 | return mprintf("<a %s id='a%d' href='%R/honeypot'>", zExtra, nHref); |
| 145 | } |
| 146 | char *href(const char *zFormat, ...){ |
| 147 | char *zUrl; |
| 148 | va_list ap; |
| 149 | va_start(ap, zFormat); |
| 150 | zUrl = vmprintf(zFormat, ap); |
| 151 | va_end(ap); |
| 152 | if( g.perm.Hyperlink && !g.javascriptHyperlink ){ |
| 153 | char *zHUrl = mprintf("<a href=\"%h\">", zUrl); |
| 154 | fossil_free(zUrl); |
| 155 | return zHUrl; |
| 156 | } |
| 157 | if( nHref>=nHrefAlloc ){ |
| 158 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 159 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 160 | } |
| 161 | aHref[nHref++] = zUrl; |
| 162 | return mprintf("<a id='a%d' href='%R/honeypot'>", nHref); |
| 163 | } |
| 164 | |
| 165 | /* |
| 166 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 167 | ** by javascript. |
| 168 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -115,53 +115,65 @@ | |
| 115 | ** |
| 116 | ** Note %z format. The string returned by this function is always |
| 117 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 118 | ** that memory space. |
| 119 | ** |
| 120 | ** There are three versions of this routine: href() does a plain hyperlink |
| 121 | ** and xhref() adds extra attribute text. The btn() version adds a |
| 122 | ** single "class='inlinebutton'" class to the anchor. |
| 123 | ** |
| 124 | ** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. |
| 125 | ** Most logged in users should have this property, since we can assume |
| 126 | ** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, |
| 127 | ** typically. |
| 128 | */ |
| 129 | char *vxhref(const char *zExtra, const char *zFormat, va_list ap){ |
| 130 | char *zUrl; |
| 131 | Blob ref = empty_blob; |
| 132 | blob_append(&ref, "<a ", 3); |
| 133 | if( zExtra ){ |
| 134 | blob_append(&ref, zExtra, -1); |
| 135 | blob_append(&ref, " ", 1); |
| 136 | } |
| 137 | zUrl = vmprintf(zFormat, ap); |
| 138 | if( g.perm.Hyperlink && !g.javascriptHyperlink ){ |
| 139 | blob_appendf(&ref,"href='%h'>", zUrl); |
| 140 | fossil_free(zUrl); |
| 141 | }else{ |
| 142 | if( nHref>=nHrefAlloc ){ |
| 143 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 144 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 145 | } |
| 146 | aHref[nHref++] = zUrl; |
| 147 | blob_appendf(&ref, "id='a%d' href='%R/honeypot'>", nHref); |
| 148 | } |
| 149 | blob_materialize(&ref); |
| 150 | return ref.aData; |
| 151 | } |
| 152 | char *xhref(const char *zExtra, const char *zFormat, ...){ |
| 153 | char *zResult; |
| 154 | va_list ap; |
| 155 | va_start(ap, zFormat); |
| 156 | zResult = vxhref(zExtra, zFormat, ap); |
| 157 | va_end(ap); |
| 158 | return zResult; |
| 159 | } |
| 160 | char *href(const char *zFormat, ...){ |
| 161 | char *zResult; |
| 162 | va_list ap; |
| 163 | va_start(ap, zFormat); |
| 164 | zResult = vxhref(0, zFormat, ap); |
| 165 | va_end(ap); |
| 166 | return zResult; |
| 167 | } |
| 168 | char *btn(const char *zFormat, ...){ |
| 169 | char *zResult; |
| 170 | va_list ap; |
| 171 | va_start(ap, zFormat); |
| 172 | zResult = vxhref("class='inlinebutton'", zFormat, ap); |
| 173 | va_end(ap); |
| 174 | return zResult; |
| 175 | } |
| 176 | |
| 177 | /* |
| 178 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 179 | ** by javascript. |
| 180 |
+1
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -535,11 +535,11 @@ | ||
| 535 | 535 | if( zOldName!=0 ){ |
| 536 | 536 | @ <li> %h(zOldName) → %h(zFilename) %s(zUnpubTag) |
| 537 | 537 | }else{ |
| 538 | 538 | @ <li> %h(zFilename) %s(zUnpubTag) |
| 539 | 539 | } |
| 540 | - @ %z(href("%R/fdiff?sbs=1&v1=%s&v2=%s",zOld,zNew))[diff]</a></li> | |
| 540 | + @ %z(btn("%R/fdiff?sbs=1&v1=%s&v2=%s",zOld,zNew))diff</a></li> | |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | db_reset(&fchngQuery); |
| 544 | 544 | if( inUl ){ |
| 545 | 545 | @ </ul> |
| 546 | 546 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -535,11 +535,11 @@ | |
| 535 | if( zOldName!=0 ){ |
| 536 | @ <li> %h(zOldName) → %h(zFilename) %s(zUnpubTag) |
| 537 | }else{ |
| 538 | @ <li> %h(zFilename) %s(zUnpubTag) |
| 539 | } |
| 540 | @ %z(href("%R/fdiff?sbs=1&v1=%s&v2=%s",zOld,zNew))[diff]</a></li> |
| 541 | } |
| 542 | } |
| 543 | db_reset(&fchngQuery); |
| 544 | if( inUl ){ |
| 545 | @ </ul> |
| 546 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -535,11 +535,11 @@ | |
| 535 | if( zOldName!=0 ){ |
| 536 | @ <li> %h(zOldName) → %h(zFilename) %s(zUnpubTag) |
| 537 | }else{ |
| 538 | @ <li> %h(zFilename) %s(zUnpubTag) |
| 539 | } |
| 540 | @ %z(btn("%R/fdiff?sbs=1&v1=%s&v2=%s",zOld,zNew))diff</a></li> |
| 541 | } |
| 542 | } |
| 543 | db_reset(&fchngQuery); |
| 544 | if( inUl ){ |
| 545 | @ </ul> |
| 546 |