Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement GitHub PR liquid tag support (#1784)
  • Loading branch information
Glennmen authored and maestromac committed Feb 15, 2019
1 parent 0b8ab21 commit 9163320
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/liquid_tags/github_tag.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(tag_name, link, tokens)
end

def issue_or_readme
if @link.include?("issues")
if @link.include?("issues") || @link.include?("pull")
"issue"
else
"readme"
Expand Down
10 changes: 9 additions & 1 deletion app/models/github_issue.rb
Expand Up @@ -20,7 +20,7 @@ def self.try_to_get_issue(url)
client = Octokit::Client.new(access_token: random_token)
issue = GithubIssue.new(url: url)
if !!(url !~ /\/issues\/comments/)
repo, issue_id = url.gsub(/.*github\.com\/repos\//, "").split("/issues/")
repo, issue_id = url.gsub(/.*github\.com\/repos\//, "").split(issue_or_pull(url))
issue.issue_serialized = get_issue_serialized(client, repo, issue_id)
issue.category = "issue"
else
Expand Down Expand Up @@ -56,4 +56,12 @@ def self.random_identity
Identity.where(provider: "github").last
end
end

def self.issue_or_pull(url)
if !url.include?("pull")
"/issues/"
else
"/pull/"
end
end
end
38 changes: 19 additions & 19 deletions app/views/pages/_editor_guide_text.html.erb
Expand Up @@ -72,41 +72,41 @@
<dl>
<dt><code>app</code></dt>
<dd>
Shows the app preview without the code.<br/>
Shows the app preview without the code.<br>
<code>{% glitch earthy-course app %}</code>
</dd>
<dt><code>code</code></dt>
<dd>
Shows the code without the app preview.<br/>
Shows the code without the app preview.<br>
<code>{% glitch earthy-course code %}</code>
</dd>
<dt><code>preview-first</code></dt>
<dd>
Hides the file browser.<br/>
Hides the file browser.<br>
<code>{% glitch earthy-course preview-first %}</code>
</dd>
<dt><code>no-attribution</code></dt>
<dd>
Hides the file browser.<br/>
Hides the file browser.<br>
<code>{% glitch earthy-course no-attribution %}</code>
</dd>
<dt><code>no-files</code></dt>
<dd>
Hides the file browser.<br/>
Hides the file browser.<br>
<code>{% glitch earthy-course no-files %}</code>
</dd>
<dt><code>file</code></dt>
<dd>
Lets you choose which file to display in the code panel. Defaults to index.html.<br/>
Lets you choose which file to display in the code panel. Defaults to index.html.<br>
<code>{% glitch earthy-course file=script.js %}</code>
</dd>

<h3><strong>GitHub Repo Embed</strong></h3>
<p>All you need is the GitHub username and repo:</p>
<code>{% github thepracticaldev/dev.to %}</code>

<h3><strong>GitHub Issue or Comment Embed</strong></h3>
<p>All you need is the GitHub issue or comment URL:</p>
<h3><strong>GitHub Issue, Pull request or Comment Embed</strong></h3>
<p>All you need is the GitHub issue, PR or comment URL:</p>
<code>{% github https://github.com/thepracticaldev/dev.to/issues/9 %}</code>

<h3><strong>GitHub Gist Embed</strong></h3>
Expand All @@ -121,7 +121,7 @@
<li><strong>YouTube:</strong> <code>{% youtube dQw4w9WgXcQ %}</code></li>
<li><strong>Vimeo:</strong> <code>{% vimeo 193110695 %}</code></li>
</ul>

<h3><strong>SlideShare Embed</strong></h3>
<p>All you need is the SlideShare <code>key</code></p>
<code>{% slideshare rdOzN9kr1yK5eE %}</code>
Expand All @@ -133,7 +133,7 @@
<dl>
<dt><code>default-tab</code></dt>
<dd>
Add default-tab parameter to your CodePen embed tag. Default to <i>result</i><br/>
Add default-tab parameter to your CodePen embed tag. Default to <i>result</i><br>
<code>{% codepen https://codepen.io/twhite96/pen/XKqrJX default-tab=js,result %}</code>
</dd>

Expand All @@ -146,7 +146,7 @@
<code>{% stackblitz ball-demo %}</code>
<dt><code>Default view</code></dt>
<dd>
You can change the default view, the options are <i>both</i>, <i>preview</i>, <i>editor</i>. Defaults to <i>both</i><br/>
You can change the default view, the options are <i>both</i>, <i>preview</i>, <i>editor</i>. Defaults to <i>both</i><br>
<code>{% stackblitz ball-demo view=preview %}</code>
</dd>

Expand All @@ -157,23 +157,23 @@
<dl>
<dt><code>initialpath</code></dt>
<dd>
Which url to initially load in address bar.<br/>
Which url to initially load in address bar.<br>
<code>{% codesandbox ppxnl191zx initialpath=/initial/load/path %}</code>
</dd>
<dt><code>module</code></dt>
<dd>
Which module to open by default.<br/>
Which module to open by default.<br>
<code>{% codesandbox ppxnl191zx module=/path/to/module %}</code>
</dd>

<h3><strong>JSFiddle Embed</strong></h3>
<p>All you need is the full JSFiddle <code>link</code>, ending in the fiddle ID code, as follows:</p>
<code>{% jsfiddle https://jsfiddle.net/link2twenty/v2kx9jcd %}</code>

<dl>
<dt><code>Custom tabs</code></dt>
<dd>
You can add a custom tab order to you JSFiddle embed tag. Defaults to <i>js,html,css,result</i><br/>
You can add a custom tab order to you JSFiddle embed tag. Defaults to <i>js,html,css,result</i><br>
<code>{% jsfiddle https://jsfiddle.net/webdevem/Q8KVC result,html,css %}</code>
</dd>

Expand All @@ -190,8 +190,8 @@
<pre>
<span style="color: gray;"># Given this embed link:</span>
< script async class="speakerdeck-embed"
data-id="<span style="color: orange;">7e9f8c0fa0c949bd8025457181913fd0</span>"
data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js">< /script >
data-id="<span style='color: orange;'>7e9f8c0fa0c949bd8025457181913fd0</span>"
data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js">< /script >
</pre>
<pre>
{% speakerdeck <span style="color: orange;">7e9f8c0fa0c949bd8025457181913fd0</span> %}
Expand Down Expand Up @@ -229,8 +229,8 @@

<h4><a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Here-Cheatsheet" target="_blank" rel="noopener">Here's the Markdown cheatsheet again for reference.</a></h4>
Happy posting! 📝
<br/>
<br/>
<br>
<br>
<div class="blank-space"></div>
</div>
</div>

0 comments on commit 9163320

Please sign in to comment.