WP Github Gist WordPress Plugin

WP Github Gist is a WordPress Plugin which provides the ability to embed gist and files from Github in your blog posts or pages. Even though Github doesn’t provide a way to embed files, this Plugin still works by using the gist-it service.

Download

You can download the Plugin as a zip file from the official WordPress Plugin repository.

Installation

Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.

Usage

Embed Gist

To embed a gist you have to use the following shortcode

  • {GIST_ID} – the id of your gist
  • {GIST_FILE} – the file inside gist that you want to display. If there is only one file in the gist, then you can ignore this.

Example

Embed Github files

To embed a github file you have to use the following shortcode

  • {GITHUB_FILE} – full path to your github file. eg: If you want to embed https://github.com/sudar/MissileLauncher/blob/master/MissileLauncher.cpp then {GITHUB_FILE} would be /sudar/MissileLauncher/blob/master/MissileLauncher.cpp
  • {START_LINE} – If you want to embed only part of the file, then you can specify the starting line number (optional)
  • {END_LINE} – If you want to embed only part of the file, then you can specify the ending line number (optional)

Example

If you want to embed only part of the file, then you can specify the start and end line as well

Changing Gist-it server

By default, this Plugin uses my own gist-it server which is hosted on a free Google App Engine account. If you expect significant amount of traffic to your blog, then do consider using your own gist-it server. You can follow the instructions to deploy your own gist-it server and then go to the settings page to change the url.

Feedback

If you have any comments or if you want to report any bugs, please leave a comment below or contact me in Twitter.

Stay updated

I would be posting updates about this Plugin in my blog and in Twitter. If you want to be informed when new version of this Plugin is released, then you can either subscribe to this blog’s RSS feed or follow me in Twitter.

TODO for Future releases

The following are the features that I am thinking of adding to the Plugin, when I get some free time. If you have any feature request or want to increase the priority of a particular feature, then let me know.

  • Provide an option to enter a different gist-it service
  • Add support for files that have spaces in them
  • Add support for github projects
  • Add support for specifying line numbers for gist as well
  • Add support for specifying a particular revision of gist
  • Add support for embedding files from other services like bitbucket and Google code

Credits

This Plugin is based on this gist-it script created by Robert Krimen

This Plugin was inspired by the Github Gist Plugin.

Change log

  • 2011-08-23 – v0.1 – Initial Release
  • 2012-05-02 – v0.2 Dev time: 0.5 hours
    • Fixed issue in embedding Github files
  • 2012-05-31 – v0.3 Dev time: 2 hours
    • Added the ability to choose gist-it server
    • Added information to the screen help tab
    • Generated Pot file for translation

23 Comments so far

Follow up comments through RSS Feed | Post a comment

  • Avdi Grimm says:

    I like the feature for showing only certain lines of a gist! Does this plugin also cache and include the source inline for the purpose of RSS feeds and search engines?

  • Ethan Brown says:

    I really like the idea and installed this plugin, but the file functionality appears to always pull in the first file that it finds in the repository–regardless of whatever file you’re trying to access. For instance, if I tried:

    [github file="/sudar/MissileLauncher/blob/master/MissileLauncher.h"]

    I’d get the code file for MissleLauncher.cpp again anyway. And that happens even if I type a file that doesn’t exist, like,

    [github file="/sudar/MissileLauncher/blob/master/nonexistentfile.lisp"]

    Have you noticed something like this issue? Are you able to pull in files that aren’t the first alphabetical one in the repository? I can do it with gist-it, but not with this plugin.

  • Hi Sudar,

    Is there a way to embed a revision of a Gist ?
    I have a step by step tutorial and wanted to have a revision for each step.

    Thanks !

  • Really good plugin, tnx, dude!

  • Azura Meta says:

    I have noticed a bug that prevents me from using this plugin:

    If the github file path contains any spaces, the plugin doesn’t display anything.
    Doesn’t work with either actual spaces or %20.

    I would appreciate if you could fix that, because otherwise it seems like a nice plugin.
    Thanks in advance!

  • Peter Chang says:

    Hello, I saw a problem in your release version, WorkoutTracker APP, which the value in EditText can not entry a dot digital number such as 3.4, 1.3, 4.567, etc.
    Q1:
    For example, if I entried the value 3.4 in this APP, the Tabs, Lists and Stats, have no problems but the Tab, Graph, can not show the plot.
    Q2:
    If I wanted to increase or to change the column table name ie. “value”–>”value01″, I must change the “DATABASE_NAME”.
    Did you have another suggestion to chang the column table name, directly.
    Thank you~~

    • Sudar says:

      I am actually confused.

      Are you talking about my WP Github Gist WordPress plugin or about the Workout Tracker Android App?

      This page is about the WP Github Gist plugin, but you are talking about the Android app here.

  • Gonza says:

    This is great mate, and it looks very neat. Thanks for it.
    Is there a way to collapse the code and add a scroll bar so a post doesn’t take half of the page if the gist is too long?
    Cheers.-

    • Sudar says:

      Glad to know that you like my plugin.

      Right now there is no way to do that since I am just using the JavaScript that is generated by github. But I will add it to my todo list.

  • Gonza says:

    Looking fwd to that. 🙂 Cheers!

  • willemdh says:

    I’m trying to show some lines of a file in a GitHub project, but it’s not showing..

    This is the shortcode I’m using:

    [github file = "/willemdh/check_ms_win_network_load/blob/master/check_ms_win_network_load.ps1" start_line = "02" end_line = "08"]

    Thanks for any help to get this working.

  • Anh Tran says:

    WordPress now supports embed Gist file directly without any plugin, but embeding a Github file is still not supported. Your plugin is very helpful!

  • Idan Adar says:

    I am getting the opposite experience with this plug-in.
    Shouldn’ github links show line numbers and gist not show line numbers?

    does not show line numbers
    test #1 – github file relative path in github command
    [github file="/IdanAdar/Change-Server-URL/blob/master/apps/ChangeServerURLApp/common/js/initOptions.js" start_line = "1" end_line = "10"]

    shows line numbers
    test #4 – gist id
    [gist id = "8b875567d0449044d65b"]

  • Adam Plocher says:

    On WordPress the plugin mentions a width and height attribute but this site doesn’t. Is that supposed to be available? It’s not working when I try it.

    Essentially I’m looking for the ability to post multiple Gists in a single blog post, but show only the first few lines (or n pixels of height) and make the rest be scrollable. I’m not seeing anything occur when I try to adjust the height.

    Thanks

11 Trackbacks/Pingbacks so far

Leave a Reply

Your email address will not be published. Required fields are marked *