github / github/pages-gem

New Gem - Insert github repo code into Github Pages

Offen
#804 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Ruby
Sterne
1.9k
Forks
360
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

New Gem Feature Request

I know Gem plug-ins are somewhat frowned upon for security and stability reasons. However, I hope this request will be met with broad acceptance.

I recently stumbled across a gem that will include your repo source code into your Github Pages Jekyll blog post. The advantage of this gem is:

  • You no longer have to copy your source code from your repo/file to your blog post.
  • You can update your repo source code without having to worry your blog will be up-to-date when your Github Pages site is rebuilt.
  • All too often people update their repo source code and think: "I'll update the blog later" but, time passes and they forget to update the blog.

The gem is pretty simple:

# Dynamically insert code block from URL
# From: https://blog.bryanroessler.com/2020-03-18-insert-code-blocks-from-repository/

require 'open-uri'

module Jekyll
    class InsertGitCode < Liquid::Tag

        def initialize(tag_name, url, tokens)
            super
            url = url.strip()
            @filename = File.basename(url)
            encoded_url = URI.encode(url)
            @file = URI.parse(encoded_url).read
        end

        def render(_context)
            @file
        end

    end
end

Liquid::Template.register_tag('insert_git_code', Jekyll::InsertGitCode)

Calling the gem is by a simple liquid tag:

{% highlight ruby %}
{% insert_git_code https://git... %}
{% endhighlight %}
Thank you for considering this request!

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

In der Anfrage werden keine Repository-Dateien, Tests oder Einstiegspunkte genannt. Beginne damit, die bestehende Jekyll- und Liquid-Integration sowie die Sicherheitsauswirkungen des entfernten Ladens von Repository-Code zu überprüfen; das Issue definiert weder eine vereinbarte Implementierung noch Abschlusskriterien.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ruby
Bereich
web-dev
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.