Search code examples
githubgithub-pagescode-snippetsgist

A snippet that contains a part of a github commit ? (without gist)


I want to display some lines of code on my website (created with GithubPages and Jekyll), extracted from a commit of my repository.

Example :

  • for some lines

https://github.com/fredericletellier/udacity-builditbigger/blob/6fe561a9e514de2e7175e2c16c5b3a1280223d2e/jokelib/src/main/java/com/joke/JokeProvider.java#L15-L22

  • for a diff of a specific file in a commit

https://github.com/fredericletellier/udacity-builditbigger/commit/6fe561a9e514de2e7175e2c16c5b3a1280223d2e?diff=unified#diff-6359bfff8a23dfc88d092acc996f6f97

But i need to quote a lot of code, and it is very long to copy-paste my code on gist. For the moment, i can provide a link to the interesting code.

Can i find a simple way to display this code in a snippet ?


UPDATE

If you have an another answer, you are welcome !


Solution

  • I found an answer : https://gist-it.appspot.com/


    The first example, file on the latest version on a branch, should not be use.

    When the code was changed, the snippet display something wrong. Prefer use the permalink to a file in a specific commit like in the second example : https://help.github.com/articles/getting-permanent-links-to-files/


    The second example, a file or a part of a file in a specific version/commit :

    <script src="http://gist-it.appspot.com/https://github.com/fredericletellier/udacity-builditbigger/blob/6fe561a9e514de2e7175e2c16c5b3a1280223d2e/jokelib/src/main/java/com/joke/JokeProvider.java?slice=14:22&footer=0"> </script>