aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 15bcb3f..ea6d18b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -356,7 +356,52 @@ void cgit_commit_link(char *name, const char *title, const char *class,
name[ctx.cfg.max_msg_len - 2] = '.';
name[ctx.cfg.max_msg_len - 3] = '.';
}
+ cgit_commit_link2(name, title, class, head, rev, path, false);
+}
+void cgit_commit_link2(char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path, bool checkForIssueLink)
+{
+ if (checkForIssueLink) {
+ int last_match = 0;
+ for (;;) {
+ const char* sub = strstr(name + last_match, "FS#");
+ if (sub != NULL) {
+ const char* sub = strstr(name + last_match, "FS#");
+ int found_pos = (sub - (name + last_match));
+ if (found_pos > 0) {
+ char* left_part = sub_str(name, last_match, last_match + found_pos);
+ cgit_commit_link3(left_part, title, class, head, rev, path);
+ free(left_part);
+ }
+ sub += 3;
+ int numbercount = 0;
+ while (*sub >= '0' && *sub <= '9') {
+ numbercount++;
+ sub++;
+ }
+ char* issue_part = sub_str(name, last_match + found_pos, last_match + found_pos + 3 + numbercount);
+ if (numbercount)
+ cgit_issue_link(issue_part);
+ else
+ cgit_commit_link3(issue_part, title, class, head, rev, path);
+ free(issue_part);
+ last_match += found_pos + 3 + numbercount;
+ } else {
+ if (strlen(name + last_match)) {
+ cgit_commit_link3(name + last_match, title, class, head, rev, path);
+ }
+ break;
+ }
+ }
+ } else {
+ cgit_commit_link3(name, title, class, head, rev, path);
+ }
+}
+
+void cgit_commit_link3(char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path)
+{
char *delim;
delim = repolink(title, class, "commit", head, path);
@@ -1117,3 +1162,49 @@ extern void cgit_author_link(const char *author, const char *head)
html_txt(author);
html("</a>");
}
+
+extern void cgit_check_text_for_issue_link(const char* text)
+{
+ int last_match = 0;
+ for (;;) {
+ const char* sub = strstr(text + last_match, "FS#");
+ if(sub != NULL) {
+ int found_pos = (sub - (text + last_match));
+ if (found_pos > 0) {
+ char* left_part = sub_str(text, last_match, last_match + found_pos);
+ html_txt(left_part);
+ free(left_part);
+ }
+ sub += 3;
+ int numbercount = 0;
+ while (*sub >= '0' && *sub <= '9') {
+ numbercount++;
+ sub++;
+ }
+ char* issue_part = sub_str(text, last_match + found_pos, last_match + found_pos + 3 + numbercount);
+ if (numbercount)
+ cgit_issue_link(issue_part);
+ else
+ html_txt(issue_part);
+ free(issue_part);
+ last_match += found_pos + 3 + numbercount;
+ } else {
+ if (strlen(text + last_match)) {
+ html_txt(text + last_match);
+ }
+ break;
+ }
+ }
+}
+
+extern void cgit_issue_link(const char* issue)
+{
+ html("<a href='");
+ htmlf(ctx.cfg.issue_link);
+ if (strlen(issue) > 3) {
+ htmlf(issue + 3);
+ }
+ html("' target='_blank'>");
+ html_txt(issue);
+ html("</a>");
+}