Skip to content

Commit

Permalink
Add auto-deployment instruction and generalize some templates.
Browse files Browse the repository at this point in the history
Former-commit-id: fc39dab6ce3c64c467f219fcce7bfffa9dd4ef11
  • Loading branch information
i2000s committed May 26, 2016
1 parent f25e6c7 commit d6d80fa
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ sudo apt-get update
sudo apt-get install pandoc
sudo apt-get install gsl-bin libgsl0-dev
```
On Windows OS, `gsl` should be preinstalled in order to gem install rb-gsl.
Otherwise, the `.travis.yml` configuration file should have some basic settings to follow.
On Windows OS, you may be able to follow [this instruction](https://davidburela.wordpress.com/2015/11/28/easily-install-jekyll-on-windows-with-3-command-prompt-entries-and-chocolatey/) to install Jekyll.
If you find some error related to Ruby Development Kit when you run `bundle exec jekyll serve` or `gem install ***`, you may find [this experience](http://flatshaded.com/2013/05/installing-jekyll-on-windows/) helpful.
`gsl` should be preinstalled in order to gem install `rb-gsl`, where the step in the `.travis.yml` configuration file about installing `gsl-bin` step does not apply to Windows systems.

The `Gemfile` and the configuration file `_conf.yml` should include sufficient information on installing correct dependences.
The `Gemfile` and the configuration files `_conf.yml` and `.travis.yml` should include sufficient information on installing correct dependences.
Then for a routinely rendering, you only need to run the following command lines:
```
bundle install
Expand All @@ -71,10 +72,44 @@ bundle exec jekyll serve
Notice that, I have locked the Jekyll version to `~>2.5.3`.
If you want to use Jekyll version 3.0.0 or above, you may need to tweak the code a little bit.

If you encounter the missing credentials error for the `twitter_feed` plugin, you may need to export environmental variables `TWIT_KEY`, `TWIT_SECRET`, `TWIT_TOK` and `TWIT_TOK_SECRET` before running the jekyll server. All the credentials of the Twitter plugin should be accessible from the TWitter account used for the site.
If you encounter the missing credentials error for the `twitter_feed` plugin, you may need to export environmental variables `TWIT_KEY`, `TWIT_SECRET`, `TWIT_TOK` and `TWIT_TOK_SECRET` before running the jekyll server. All the credentials of the Twitter plugin should be accessible from the TWitter account used for the site.

By default, the local build should be accessible at `http://127.0.0.1:4000` on your internet browser.

How to adapt this source code to generate your own Jekyll website
=================================================================
Since Jekyll uses a very efficient way to control common information in fewer places, you can easily modify the source code of this website to generate your own website on GitHub and deploy to elsewhere.
In fact, when the site was initially designed and modified especially to my end, it has always been a common goal to make it easy for the community to migrate this source code to other web hosts and adapt to various purposes.
I encourage you to post an issue or make a pull request on this repo or the original [labnotebook repo](http://carlboettiger.info) if you find a way to improve the general design.
Only in this way, the network of people who have adapted this design to their sites can benefit most from the continuous improvement by the community who are following this body of code for open science and beyond.
Below are the minimum changes you need to make to serve your own purpose of using the source code.

1. Fork this repo under your GitHub account.

2. Change information defined in the `_config.yml` file for your case.
There you will find definitions for your site, Github account and repo information, as well as your personal contact information.

3. Add encrypted information in the `.travis.yml` file.
There you will find the `env/global` section where global variables are defined to automatically generate twitter timeline, github comment history and [deploy the site as gh-pages on the Travis-CI server](http://awestruct.org/auto-deploy-to-github-pages/).
You should remove all the original code starting with `secure` and replace with your own encrypted codes line by line in the `.travis.yml` file or on the Travis-CI setting page.
The recommended minimum global variables to be encrypted are: [Github Token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) (variable name `GH_TOKEN`), git commit author name (`GIT_NAME`), git commit author email (`GIT_EMAIL`);
if you want to generate a Twitter message line on your site using the `twitter_feed.rb` plugin, you will also need to encrypt Twitter key (`TWIT_KEY`), secret (`TWIT_SECRET`), token (`TWIT_TOK`), token secret (`TWIT_TOK_SECRET`).
Before you commit this step, make sure you have [ativated the Travis-CI module for your Github repo](https://travis-ci.org/getting_started).
You can then generate the encrypted variables by installing travis while on your local repo directory with command `gem install travis` and using the following command line format `travis encrypt GIT_NAME="Xiaodong Qi"`.
You should replace the variable name and value with the real cases as bash commands one after one.
Notice that when the variable value has a space inside, you need to use a pair of quotation marks as the example I gave--otherwise no need to use quotation marks in most cases; if you have special characters that bash command doesn't like, you need to [escape those characters](http://wiki.bash-hackers.org/syntax/quoting).
The last command line should generate a long string of random characters which you should be able to add to the `env/global` section of the `.travis.yml` file in the format of `- secure Your_Encrypt_Random_bits`.
You can certainly add more encrypt variables or define some non-sensitive variables as explicit/non-encrypted variables in a similar way, but the Github token has to be encrypted to pass the security check of Github.

4. If you have different amount of social accounts or plugin items defined in the `_config.yml` file, you need to double modify the scripts appeared in the header and footer template under the `_include` directory.

The publication and citation databases are defined in the `asset` directory as bibtex files with suffix `.bib`, which may want to replace with your own.
The rest is to delete or keep posts and pages to fit into your needs.
I suggest to put this source code in a branch other than `master` or `gh-pages` in your Github repository, which you need to define in the `_config.yml` file as the "sourcebranch".
The Travis-CI server will commit the generate website onto the `master` or `gh-pages` github branch depending on your case.
Once you have all the necessary configurations done, Travis-CI will be happily deploying your site on Github.
If you want the site to be deployed on a host other than Github, you may want to modify and run the `publish.sh` bash script to synchronize your locally generated `_site` folder or the master/gh-pages branch updated by Travis-CI to your target site host.

Authorships of posts before Feb 10th, 2016
=========================================
Since this site was basically built on top of [David Ketcheson](http://davidketcheson.info) and [Carl Boettiger](http://carlboettiger.info)'s Labnotebook sites following the permitted Creative Commons license, please be advised that blog posts time-stamped before Feb 10th of 2016 may be written by David Ketcheson or Carl Boettiger.
Expand Down
4 changes: 3 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ author :
- name: JuliaCN
url: http://i2000s.github.io
disqus:
sitename: qxd
sitename: qxd # This is the shortname of the disqus site id to display disqus comments below posts.
addthis:
pubid: ra-54f225a84524edd3 # This is the AddThis button pubid to display social sharing buttons on the website. Used in the header template.
navigation: # For the navigation menu. Don't use index.html. urls should end with a directory.
- text: Home
url: /
Expand Down
8 changes: 4 additions & 4 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<![endif]-->
<meta name="subtitle" content="{{ page.subtitle }}">
<meta name="author" content="{{site.author.name}} | {{site.author.ChineseName}}">

{% include metadata.html %}
<!-- Le styles -->
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Quattrocento+Sans:bold,bolditalic,italic|Quattrocento+Sans">
Expand All @@ -27,10 +27,10 @@
<link rel="stylesheet" type="text/css" href="/assets/css/style.css">

{% include analytics.html %}

<!-- Help the browser identify the RSS feed automatically -->
<link rel="alternate" type="application/rss+xml" title="Xiaodong Qi's Website" href="/atom.xml" />

<!-- favicon -->
<link rel="apple-touch-icon" sizes="57x57" href="/assets/img/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/assets/img/favicon/apple-icon-60x60.png">
Expand All @@ -52,7 +52,7 @@
</head>

<!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-54f225a84524edd3" async="async"></script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{site.addthis.pubid}}" async="async"></script>

<body>

Expand Down
6 changes: 3 additions & 3 deletions _includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
<!-- Search site using Google's index -->
<form class="navbar-form navbar-right" role="search" method="get" action="http://google.com/search">
<div class="form-group">
<input type="hidden" name="q" value="site:i2000s.github.io" />
<input type="hidden" name="q" value="site:{{site.url}}" />
<input type="text" class="form-control search-query" name="q" placeholder="Search this site"/>
</div>
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</form>

</div><!--/.nav-collapse -->
</div> <!-- /container -->
</nav>
</nav>
4 changes: 2 additions & 2 deletions _includes/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>

<!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-54f225a84524edd3" async="async"></script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{site.addthis.pubid}}" async="async"></script>

<body data-spy="scroll" data-target=".subnav" data-offset="50">

Expand Down Expand Up @@ -90,7 +90,7 @@ <h1 class="entry-title">{{ page.title }}</h1>

<div class="row">
<div class="span2">
<iframe class="github-btn" src="http://markdotto.github.com/github-buttons/github-btn.html?user=i2000s&repo=i2000s.github.com&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="98px" height="20px"></iframe>
<iframe class="github-btn" src="http://markdotto.github.com/github-buttons/github-btn.html?user={{site.username}}&repo={{site.repo}}&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="98px" height="20px"></iframe>
</div>
<div class="span1 offset8">
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/"><img src="https://licensebuttons.net/l/by/3.0/88x31.png" style="float:left;margin:0 5 0 0;" alt="CC-BY" /></a>
Expand Down

0 comments on commit d6d80fa

Please sign in to comment.