Hard Light Productions Forums

Site Management => Site Support / Feedback => Topic started by: jg18 on June 14, 2021, 01:01:18 pm

Title: Suggestion: Add a "gh" BBCode tag for easy reference to FSO GitHub Issues/PRs
Post by: jg18 on June 14, 2021, 01:01:18 pm
It would be handy to have an easy way to insert references to FSO GitHub issues (https://github.com/scp-fs2open/fs2open.github.com/issues) and pull requests (https://github.com/scp-fs2open/fs2open.github.com/pulls). How about a new "gh" tag?

Suggested syntax

Code: [Select]
[gh]Issue #3336[/gh]

would turn into

Issue #3336 (https://github.com/scp-fs2open/fs2open.github.com/issues/3336)

and

Code: [Select]
[gh]PR #3398[/gh]

would turn into

PR #3398 (https://github.com/scp-fs2open/fs2open.github.com/pull/3398)

If "gh" is confusing, the tag could be "github" instead.

Thoughts?
Title: Re: Suggestion: Add a "gh" BBCode tag for easy reference to FSO GitHub Issues/PRs
Post by: EatThePath on June 14, 2021, 05:50:05 pm
I don't know exactly what would be needed to be done to implement this... but I bet I know enough of the relevant languages to figure it out if given the access, and would be willing to take a crack at it if the existing admin pool thinks this is a good idea but not one they're prepared to dive into.
Title: Re: Suggestion: Add a "gh" BBCode tag for easy reference to FSO GitHub Issues/PRs
Post by: Goober5000 on June 14, 2021, 05:58:48 pm
The forum is written in PHP, and the code is publicly downloadable at simplemachines.org.  Here's how the URL tag is set up:

Code: [Select]
array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener noreferrer">$1</a>',
'validate' => function(&$tag, &$data, $disabled)
{
if (strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
$data = '//' . $data;
},
),
Title: Re: Suggestion: Add a "gh" BBCode tag for easy reference to FSO GitHub Issues/PRs
Post by: ngld on July 09, 2021, 02:19:58 pm
Done. I've used a simple regex to find the # number which means that "PR #123" and "PR #123: Some test" work but "PR #123a" doesn't. "Did you look at #123 already?" would work as well. Just make sure that your text contains #<number><some kind of separator like " ", ":", ".", ...> somwhere.

The current tag always links to the FSO repo. I could add [gh=pcs2], [gh=knossos], ... as well if there's interest.

EDIT: I've also added the gh and fsolog tags to the toolbar as well since I keep forgetting them.
Title: Re: Suggestion: Add a "gh" BBCode tag for easy reference to FSO GitHub Issues/PRs
Post by: jg18 on July 09, 2021, 11:26:20 pm
Sweet! It works great. :D Thanks, ngld! :yes: