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

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

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