SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Más de Innovecs

Más 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
 

Último

Último (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

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