Fossil SCM
Convenience "copy" button before dates on the /info and /forumpost pages.
Commit
e39933757acd4c06ec9f2b72cafe9ee614a2943bc5ee5b07f1c663998d29684d
Parent
7404ad0b0e08b99…
4 files changed
+2
+6
-1
+4
-1
+4
+2
| --- src/copybtn.js | ||
| +++ src/copybtn.js | ||
| @@ -66,10 +66,12 @@ | ||
| 66 | 66 | if( elTarget ){ |
| 67 | 67 | var text = elTarget.innerText.replace(/^\s+|\s+$/g,""); |
| 68 | 68 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 69 | 69 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 70 | 70 | text = text.slice(0,cchLength); /* Assume single-byte chars. */ |
| 71 | + }else if( /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(text) ){ | |
| 72 | + text = text.replace(' ', 'T'); | |
| 71 | 73 | } |
| 72 | 74 | copyTextToClipboard(text); |
| 73 | 75 | } |
| 74 | 76 | } |
| 75 | 77 | /* Create a temporary <textarea> element and copy the contents to clipboard. */ |
| 76 | 78 |
| --- src/copybtn.js | |
| +++ src/copybtn.js | |
| @@ -66,10 +66,12 @@ | |
| 66 | if( elTarget ){ |
| 67 | var text = elTarget.innerText.replace(/^\s+|\s+$/g,""); |
| 68 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 69 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 70 | text = text.slice(0,cchLength); /* Assume single-byte chars. */ |
| 71 | } |
| 72 | copyTextToClipboard(text); |
| 73 | } |
| 74 | } |
| 75 | /* Create a temporary <textarea> element and copy the contents to clipboard. */ |
| 76 |
| --- src/copybtn.js | |
| +++ src/copybtn.js | |
| @@ -66,10 +66,12 @@ | |
| 66 | if( elTarget ){ |
| 67 | var text = elTarget.innerText.replace(/^\s+|\s+$/g,""); |
| 68 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 69 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 70 | text = text.slice(0,cchLength); /* Assume single-byte chars. */ |
| 71 | }else if( /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(text) ){ |
| 72 | text = text.replace(' ', 'T'); |
| 73 | } |
| 74 | copyTextToClipboard(text); |
| 75 | } |
| 76 | } |
| 77 | /* Create a temporary <textarea> element and copy the contents to clipboard. */ |
| 78 |
+6
-1
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -763,10 +763,11 @@ | ||
| 763 | 763 | char *zQuery /* Common query string */ |
| 764 | 764 | ){ |
| 765 | 765 | char *zPosterName; /* Name of user who originally made this post */ |
| 766 | 766 | char *zEditorName; /* Name of user who provided the current edit */ |
| 767 | 767 | char *zDate; /* The time/date string */ |
| 768 | + char *zDateTag; /* Tag for the time/date text */ | |
| 768 | 769 | char *zHist; /* History query string */ |
| 769 | 770 | Manifest *pManifest; /* Manifest comprising the current post */ |
| 770 | 771 | int bPrivate; /* True for posts awaiting moderation */ |
| 771 | 772 | int bSameUser; /* True if author is also the reader */ |
| 772 | 773 | int iIndent; /* Indent level */ |
| @@ -809,10 +810,11 @@ | ||
| 809 | 810 | }else{ |
| 810 | 811 | zPosterName = forum_post_display_name(p, pManifest); |
| 811 | 812 | zEditorName = zPosterName; |
| 812 | 813 | } |
| 813 | 814 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 815 | + zDateTag = mprintf("datetag-%d", p->fpid); | |
| 814 | 816 | if( p->pEditPrev ){ |
| 815 | 817 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 816 | 818 | zEditorName = forum_post_display_name(p, pManifest); |
| 817 | 819 | zHist = bHist ? "" : zQuery[0]==0 ? "?hist" : "&hist"; |
| 818 | 820 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| @@ -828,13 +830,16 @@ | ||
| 828 | 830 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 829 | 831 | } |
| 830 | 832 | }else{ |
| 831 | 833 | zPosterName = forum_post_display_name(p, pManifest); |
| 832 | 834 | @ <h3 class='forumPostHdr'>(%d(p->sid)) |
| 833 | - @ By %s(zPosterName) on %h(zDate) | |
| 835 | + @ By %s(zPosterName) on \ | |
| 836 | + style_copy_button(1, zDateTag, 0, 0, "%h", zDate); | |
| 837 | + cgi_printf(" "); | |
| 834 | 838 | } |
| 835 | 839 | fossil_free(zDate); |
| 840 | + fossil_free(zDateTag); | |
| 836 | 841 | |
| 837 | 842 | |
| 838 | 843 | /* If debugging is enabled, link to the artifact page. */ |
| 839 | 844 | if( g.perm.Debug ){ |
| 840 | 845 | @ <span class="debug">\ |
| 841 | 846 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -763,10 +763,11 @@ | |
| 763 | char *zQuery /* Common query string */ |
| 764 | ){ |
| 765 | char *zPosterName; /* Name of user who originally made this post */ |
| 766 | char *zEditorName; /* Name of user who provided the current edit */ |
| 767 | char *zDate; /* The time/date string */ |
| 768 | char *zHist; /* History query string */ |
| 769 | Manifest *pManifest; /* Manifest comprising the current post */ |
| 770 | int bPrivate; /* True for posts awaiting moderation */ |
| 771 | int bSameUser; /* True if author is also the reader */ |
| 772 | int iIndent; /* Indent level */ |
| @@ -809,10 +810,11 @@ | |
| 809 | }else{ |
| 810 | zPosterName = forum_post_display_name(p, pManifest); |
| 811 | zEditorName = zPosterName; |
| 812 | } |
| 813 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 814 | if( p->pEditPrev ){ |
| 815 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 816 | zEditorName = forum_post_display_name(p, pManifest); |
| 817 | zHist = bHist ? "" : zQuery[0]==0 ? "?hist" : "&hist"; |
| 818 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| @@ -828,13 +830,16 @@ | |
| 828 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 829 | } |
| 830 | }else{ |
| 831 | zPosterName = forum_post_display_name(p, pManifest); |
| 832 | @ <h3 class='forumPostHdr'>(%d(p->sid)) |
| 833 | @ By %s(zPosterName) on %h(zDate) |
| 834 | } |
| 835 | fossil_free(zDate); |
| 836 | |
| 837 | |
| 838 | /* If debugging is enabled, link to the artifact page. */ |
| 839 | if( g.perm.Debug ){ |
| 840 | @ <span class="debug">\ |
| 841 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -763,10 +763,11 @@ | |
| 763 | char *zQuery /* Common query string */ |
| 764 | ){ |
| 765 | char *zPosterName; /* Name of user who originally made this post */ |
| 766 | char *zEditorName; /* Name of user who provided the current edit */ |
| 767 | char *zDate; /* The time/date string */ |
| 768 | char *zDateTag; /* Tag for the time/date text */ |
| 769 | char *zHist; /* History query string */ |
| 770 | Manifest *pManifest; /* Manifest comprising the current post */ |
| 771 | int bPrivate; /* True for posts awaiting moderation */ |
| 772 | int bSameUser; /* True if author is also the reader */ |
| 773 | int iIndent; /* Indent level */ |
| @@ -809,10 +810,11 @@ | |
| 810 | }else{ |
| 811 | zPosterName = forum_post_display_name(p, pManifest); |
| 812 | zEditorName = zPosterName; |
| 813 | } |
| 814 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 815 | zDateTag = mprintf("datetag-%d", p->fpid); |
| 816 | if( p->pEditPrev ){ |
| 817 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 818 | zEditorName = forum_post_display_name(p, pManifest); |
| 819 | zHist = bHist ? "" : zQuery[0]==0 ? "?hist" : "&hist"; |
| 820 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| @@ -828,13 +830,16 @@ | |
| 830 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 831 | } |
| 832 | }else{ |
| 833 | zPosterName = forum_post_display_name(p, pManifest); |
| 834 | @ <h3 class='forumPostHdr'>(%d(p->sid)) |
| 835 | @ By %s(zPosterName) on \ |
| 836 | style_copy_button(1, zDateTag, 0, 0, "%h", zDate); |
| 837 | cgi_printf(" "); |
| 838 | } |
| 839 | fossil_free(zDate); |
| 840 | fossil_free(zDateTag); |
| 841 | |
| 842 | |
| 843 | /* If debugging is enabled, link to the artifact page. */ |
| 844 | if( g.perm.Debug ){ |
| 845 | @ <span class="debug">\ |
| 846 |
+4
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1070,11 +1070,14 @@ | ||
| 1070 | 1070 | @ (Record ID: %d(rid)) |
| 1071 | 1071 | } |
| 1072 | 1072 | @ </td></tr> |
| 1073 | 1073 | @ <tr><th>User & Date:</th><td> |
| 1074 | 1074 | hyperlink_to_user(zUser,zDate," on "); |
| 1075 | - hyperlink_to_date(zDate, "</td></tr>"); | |
| 1075 | + style_copy_button(1, "date-ci", 0, 0, | |
| 1076 | + "%z%h</a>", href("%R/timeline?c=%T",zDate), zDate); | |
| 1077 | + @ </td></tr> | |
| 1078 | + // hyperlink_to_date(zDate, "</td></tr>"); | |
| 1076 | 1079 | if( zEComment ){ |
| 1077 | 1080 | @ <tr><th>Original Comment:</th> |
| 1078 | 1081 | @ <td class="infoComment">%!W(zComment)</td></tr> |
| 1079 | 1082 | } |
| 1080 | 1083 | if( fossil_strcmp(zDate, zOrigDate)!=0 |
| 1081 | 1084 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1070,11 +1070,14 @@ | |
| 1070 | @ (Record ID: %d(rid)) |
| 1071 | } |
| 1072 | @ </td></tr> |
| 1073 | @ <tr><th>User & Date:</th><td> |
| 1074 | hyperlink_to_user(zUser,zDate," on "); |
| 1075 | hyperlink_to_date(zDate, "</td></tr>"); |
| 1076 | if( zEComment ){ |
| 1077 | @ <tr><th>Original Comment:</th> |
| 1078 | @ <td class="infoComment">%!W(zComment)</td></tr> |
| 1079 | } |
| 1080 | if( fossil_strcmp(zDate, zOrigDate)!=0 |
| 1081 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1070,11 +1070,14 @@ | |
| 1070 | @ (Record ID: %d(rid)) |
| 1071 | } |
| 1072 | @ </td></tr> |
| 1073 | @ <tr><th>User & Date:</th><td> |
| 1074 | hyperlink_to_user(zUser,zDate," on "); |
| 1075 | style_copy_button(1, "date-ci", 0, 0, |
| 1076 | "%z%h</a>", href("%R/timeline?c=%T",zDate), zDate); |
| 1077 | @ </td></tr> |
| 1078 | // hyperlink_to_date(zDate, "</td></tr>"); |
| 1079 | if( zEComment ){ |
| 1080 | @ <tr><th>Original Comment:</th> |
| 1081 | @ <td class="infoComment">%!W(zComment)</td></tr> |
| 1082 | } |
| 1083 | if( fossil_strcmp(zDate, zOrigDate)!=0 |
| 1084 |
+4
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -497,10 +497,14 @@ | ||
| 497 | 497 | ** <= 0: Use all of the text |
| 498 | 498 | ** >= 3: Truncate the text after mxLength bytes. |
| 499 | 499 | ** 1: Use the "hash-digits" setting as the limit. |
| 500 | 500 | ** 2: Use the length appropriate for URLs as the limit (defined at |
| 501 | 501 | ** compile-time by FOSSIL_HASH_DIGITS_URL, defaults to 16). |
| 502 | +** | |
| 503 | +** Note: If the text to be copied is an ISO8601 date-time with a space | |
| 504 | +** separator between the date and the time, that space is converted to "T" | |
| 505 | +** for the copy. | |
| 502 | 506 | */ |
| 503 | 507 | char *style_copy_button( |
| 504 | 508 | int bOutputCGI, /* Don't return result, but send to cgi_printf(). */ |
| 505 | 509 | const char *zTargetId, /* HTML id of the text */ |
| 506 | 510 | int bFlipped, /* True to put copy button after text */ |
| 507 | 511 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -497,10 +497,14 @@ | |
| 497 | ** <= 0: Use all of the text |
| 498 | ** >= 3: Truncate the text after mxLength bytes. |
| 499 | ** 1: Use the "hash-digits" setting as the limit. |
| 500 | ** 2: Use the length appropriate for URLs as the limit (defined at |
| 501 | ** compile-time by FOSSIL_HASH_DIGITS_URL, defaults to 16). |
| 502 | */ |
| 503 | char *style_copy_button( |
| 504 | int bOutputCGI, /* Don't return result, but send to cgi_printf(). */ |
| 505 | const char *zTargetId, /* HTML id of the text */ |
| 506 | int bFlipped, /* True to put copy button after text */ |
| 507 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -497,10 +497,14 @@ | |
| 497 | ** <= 0: Use all of the text |
| 498 | ** >= 3: Truncate the text after mxLength bytes. |
| 499 | ** 1: Use the "hash-digits" setting as the limit. |
| 500 | ** 2: Use the length appropriate for URLs as the limit (defined at |
| 501 | ** compile-time by FOSSIL_HASH_DIGITS_URL, defaults to 16). |
| 502 | ** |
| 503 | ** Note: If the text to be copied is an ISO8601 date-time with a space |
| 504 | ** separator between the date and the time, that space is converted to "T" |
| 505 | ** for the copy. |
| 506 | */ |
| 507 | char *style_copy_button( |
| 508 | int bOutputCGI, /* Don't return result, but send to cgi_printf(). */ |
| 509 | const char *zTargetId, /* HTML id of the text */ |
| 510 | int bFlipped, /* True to put copy button after text */ |
| 511 |