SlideShare a Scribd company logo
1 of 21
GITHUB API: GITHUB
COMMENTS IN JEKYLL

Tech Hangout #32
by Valera Rozuvan

11 December 2013
Transform your plain text into static
websites and blogs.
Why?
Simple
No
more
databases,
comment moderation, or
pesky updates.

Blog-aware
Permalinks, categories,
pages,
posts,
and
custom layouts.

Static
Markdown (or Textile), Liquid,
HTML & CSS go in. Static
sites come out.

GitHub Pages
You can easily deploy your
site using GitHub for free.
Custom domain too.
Dr. Jekyll & Mr. Hyde
Installing Ruby & RubyGems
On Ubuntu 12.04 LTS this is very simple:
$ sudo apt­get update
$ sudo apt­get install curl
$ curl ­L https://get.rvm.io | bash ­s stable
$ source ~/.rvm/scripts/rvm
$ rvm requirements
$ rvm install ruby
$ rvm use ruby –default
$ rvm rubygems current
Installing Jekyll
This is the easy part ;)
$ gem install jekyll

Setting up a new blog
$ jekyll new myblog
$ cd myblog
$ jekyll serve
Hosting on GitHub
Every GitHub repository can have a special branch called
gh-pages. You can place in this branch any static files
(HTML, CSS, JavaScript, images, text, etc.) and it will be
served from a server. The access URL is:
http://user.github.io/repository
Do note that this is static hosting! No PHP, Python, etc.
Also, there is a delay between the time you push to
GitHub the gh-pages branch and the time it will become
accessible via the access URL.
Deploying Jekyll to GitHub
The sources of the Jekyll blog will be placed in the
master branch of our repository. Since we can't
directly make GitHub serve Jekyll sources, we will tell
Jekyll to generate all static content beforehand. The
static content will be placed in the gh-pages branch.
To generate a Jekyll blog:
$ jekyll build 
> ­­source <source> 
> ­­destination <destination>
Tip
The best work-flow is to have two separate directories, each
being a clone of the working GitHub repository. In one directory
you have the master branch checked out, and in the other you
have the gh-pages branch checked out. Then updating your
blog is as simple as:
... edit <master_dir> content ...
$ jekyll build ­s <master_dir> ­d <gh_pages_dir>
$ cd <gh_pages_dir>
$ git commit ­a ­m "Updated blog."
$ git push origin gh­pages
Don't forget!
1. In _config.yml, set the baseurl option to /projectname – note the leading slash and the absence of a
trailing slash.
2. When referencing JS or CSS files, do it like this:
{{ site.baseurl }}/path/to/css.css – note the slash
immediately following the variable (just before
“path”).
3. When doing permalinks or internal links, do it like
this: {{ site.baseurl }}{{ post.url }} – note that there
is no slash between the two variables.
What about comments?
Can't we use GitHub
to store comments?
Yes. Yes,
we can.

Each blog post is basically
a file in a commit. A commit
can have messages attached
to it. We can use the commit
messaging system as a
commenting system!
How do we access GitHub commit
comments from our blog?

GitHub API to the rescue!
The technical details
1. Register a new OAuth GitHub application:
https://github.com/settings/applications/new
2. Use the following URLs to make AJAX requests regarding commits,
and their comments:
•

•

https://api.github.com/repos/{{user}}/
{{repository}}/commits?path=_posts%2F{{name of 
blog post file}}
https://api.github.com/repos/{{user}}/
{{repository}}/commits/{{commit hash}}/comments

Unfortunately, this method lacks authentication. GitHub limits
unauthenticated requests to something like 60 requests per hour.
An awesome developer known by the GitHub
handle m2w developed just such a
commenting
system. You can check it out at:

https://github.com/m2w/talaria
A bit of code
&
Demo
Useful links
●

http://goo.gl/pBXFGD [how to install Ruby and RubyGem on
Ubuntu 12.04 LTS]

●

http://jekyllrb.com/docs/quickstart/

●

http://jekyllrb.com/docs/usage/

●

http://jekyllrb.com/docs/github-pages/

●

http://goo.gl/ffF9vC [creating GitHub pages manually]

●

https://github.com/m2w/talaria

●

http://blog.tibidat.com/talaria/

●

http://blog.tibidat.com/

●

https://github.com/settings/applications/new
Thanks!
ValeraRozuvan

valera­rozuvan

http://valera.rozuvan.net
Github API: Github comments in Jekyll - Tech Hangout #32 - 2013.12.11

More Related Content

More from Innovecs

More from Innovecs (20)

Web Platform for Fashion Shop
Web Platform for Fashion ShopWeb Platform for Fashion Shop
Web Platform for Fashion Shop
 
Programmatic Advertising Platform
Programmatic Advertising PlatformProgrammatic Advertising Platform
Programmatic Advertising Platform
 
Multimedia Newsroom
Multimedia NewsroomMultimedia Newsroom
Multimedia Newsroom
 
Media Buying Platform (DSP+DPM)
Media Buying Platform (DSP+DPM)Media Buying Platform (DSP+DPM)
Media Buying Platform (DSP+DPM)
 
Web-based Shipment Application
Web-based Shipment ApplicationWeb-based Shipment Application
Web-based Shipment Application
 
Digital Trading Platform
Digital Trading PlatformDigital Trading Platform
Digital Trading Platform
 
Mobile Insurance Agent
Mobile Insurance AgentMobile Insurance Agent
Mobile Insurance Agent
 
Online Learning Platform
Online Learning PlatformOnline Learning Platform
Online Learning Platform
 
Client Bank
Client BankClient Bank
Client Bank
 
Fertility Tracking App
Fertility Tracking AppFertility Tracking App
Fertility Tracking App
 
Warranty Wallet App
Warranty Wallet AppWarranty Wallet App
Warranty Wallet App
 
Online Bingo Game
Online Bingo GameOnline Bingo Game
Online Bingo Game
 
Secure Messenger
Secure MessengerSecure Messenger
Secure Messenger
 
Search Data Platform
Search Data PlatformSearch Data Platform
Search Data Platform
 
Website Builder for Insurance Agents
Website Builder for Insurance AgentsWebsite Builder for Insurance Agents
Website Builder for Insurance Agents
 
United Trading Platform
United Trading PlatformUnited Trading Platform
United Trading Platform
 
Match3 Game
Match3 GameMatch3 Game
Match3 Game
 
Online Trading Platform
Online Trading PlatformOnline Trading Platform
Online Trading Platform
 
Performance Platform TLA
Performance Platform TLAPerformance Platform TLA
Performance Platform TLA
 
Slot Video Game
Slot Video GameSlot Video Game
Slot Video Game
 

Recently uploaded

ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
ashishpaul799
 

Recently uploaded (20)

Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptx
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdf
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdf
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 

Github API: Github comments in Jekyll - Tech Hangout #32 - 2013.12.11

  • 1. GITHUB API: GITHUB COMMENTS IN JEKYLL Tech Hangout #32 by Valera Rozuvan 11 December 2013
  • 2. Transform your plain text into static websites and blogs.
  • 3. Why? Simple No more databases, comment moderation, or pesky updates. Blog-aware Permalinks, categories, pages, posts, and custom layouts. Static Markdown (or Textile), Liquid, HTML & CSS go in. Static sites come out. GitHub Pages You can easily deploy your site using GitHub for free. Custom domain too.
  • 4. Dr. Jekyll & Mr. Hyde
  • 5. Installing Ruby & RubyGems On Ubuntu 12.04 LTS this is very simple: $ sudo apt­get update $ sudo apt­get install curl $ curl ­L https://get.rvm.io | bash ­s stable $ source ~/.rvm/scripts/rvm $ rvm requirements $ rvm install ruby $ rvm use ruby –default $ rvm rubygems current
  • 6. Installing Jekyll This is the easy part ;) $ gem install jekyll Setting up a new blog $ jekyll new myblog $ cd myblog $ jekyll serve
  • 7. Hosting on GitHub Every GitHub repository can have a special branch called gh-pages. You can place in this branch any static files (HTML, CSS, JavaScript, images, text, etc.) and it will be served from a server. The access URL is: http://user.github.io/repository Do note that this is static hosting! No PHP, Python, etc. Also, there is a delay between the time you push to GitHub the gh-pages branch and the time it will become accessible via the access URL.
  • 8. Deploying Jekyll to GitHub The sources of the Jekyll blog will be placed in the master branch of our repository. Since we can't directly make GitHub serve Jekyll sources, we will tell Jekyll to generate all static content beforehand. The static content will be placed in the gh-pages branch. To generate a Jekyll blog: $ jekyll build  > ­­source <source>  > ­­destination <destination>
  • 9.
  • 10. Tip The best work-flow is to have two separate directories, each being a clone of the working GitHub repository. In one directory you have the master branch checked out, and in the other you have the gh-pages branch checked out. Then updating your blog is as simple as: ... edit <master_dir> content ... $ jekyll build ­s <master_dir> ­d <gh_pages_dir> $ cd <gh_pages_dir> $ git commit ­a ­m "Updated blog." $ git push origin gh­pages
  • 11. Don't forget! 1. In _config.yml, set the baseurl option to /projectname – note the leading slash and the absence of a trailing slash. 2. When referencing JS or CSS files, do it like this: {{ site.baseurl }}/path/to/css.css – note the slash immediately following the variable (just before “path”). 3. When doing permalinks or internal links, do it like this: {{ site.baseurl }}{{ post.url }} – note that there is no slash between the two variables.
  • 12.
  • 14. Can't we use GitHub to store comments? Yes. Yes, we can. Each blog post is basically a file in a commit. A commit can have messages attached to it. We can use the commit messaging system as a commenting system!
  • 15. How do we access GitHub commit comments from our blog? GitHub API to the rescue!
  • 16. The technical details 1. Register a new OAuth GitHub application: https://github.com/settings/applications/new 2. Use the following URLs to make AJAX requests regarding commits, and their comments: • • https://api.github.com/repos/{{user}}/ {{repository}}/commits?path=_posts%2F{{name of  blog post file}} https://api.github.com/repos/{{user}}/ {{repository}}/commits/{{commit hash}}/comments Unfortunately, this method lacks authentication. GitHub limits unauthenticated requests to something like 60 requests per hour.
  • 17. An awesome developer known by the GitHub handle m2w developed just such a commenting system. You can check it out at: https://github.com/m2w/talaria
  • 18. A bit of code & Demo
  • 19. Useful links ● http://goo.gl/pBXFGD [how to install Ruby and RubyGem on Ubuntu 12.04 LTS] ● http://jekyllrb.com/docs/quickstart/ ● http://jekyllrb.com/docs/usage/ ● http://jekyllrb.com/docs/github-pages/ ● http://goo.gl/ffF9vC [creating GitHub pages manually] ● https://github.com/m2w/talaria ● http://blog.tibidat.com/talaria/ ● http://blog.tibidat.com/ ● https://github.com/settings/applications/new