SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Plus de Innovecs

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

Plus de 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
 

Dernier

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
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Ữ Â...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
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.pptxMaritesTamaniVerdade
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
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 17Celine George
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Dernier (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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Ữ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
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
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
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
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

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