特性
- 常量前面没有美元符号($);
- 常量只能用 define() 函数定义,而不能通过赋值语句;
- 常量可以不用理会变量范围的规则而在任何地方定义和访问;
- 常量一旦定义就不能被重新定义或者取消定义;
- 常量的值只能是标量;
- 常量只能包含标量数据(boolean,integer,float 和 string),不要定义 resource常量.
先看下jekyll目前的最新版本和所需ruby的版本,当前jekyll版本v2.5.3,对ruby版本要求是>= 1.9.3
1 | louxiaojian@dao:~$ sudo apt-get install ruby ruby-dev |
http://dayanjia.com/2010/10/9-confusing-naming-conventions-for-beginners-in-web-programming.html
当人们一开始接触各种Web开发语言时,总会发现彻底搞懂不同语言的命名约定是一件很要命的事情。而且当开发者在争论什么才是最佳实践时,事情会变得更加让人困惑。为了让初学者更容易地在不同语言中过渡,这篇文章列出了一些常见的约定。
如果你看到一个变量或者方法是以_开头的,其实这并不代表其幕后有什么猫腻。这仅仅是为了提醒开发者这个变量/属性/方法是私有的(private
)或是受保护的(protected
),它们不能从类的外部访问到。
1 | class MyClass { |
From:http://www.oschina.net/question/12_21806
为了让 Node.js 输出更多的 HTML 元素,我们可以借助一些 html 模板引擎,例如 Mustache。
首先在 Node.js 中安装 Mustache:
npm install mustache
这会创建一个目录:node_modules\mustache
然后我们可以编写代码:
var mustache = require(‘./node_modules/mustache/mustache’);
function helloworld(response)
{
console.log(‘request recieved at ‘ + (new Date()).getTime());
response.writeHead(200, {‘Content-Type’: ‘text/html’});
var template = ‘<h1>Test</h1><p></p>’;
var model = {helloworld:’Hello World’};
response.end(mustache.to_html(template,model));
}
exports.helloworld = helloworld;
From:https://github.com/mojombo/jekyll/wiki/Usage
Note: Pagination does not work with markdown files, it only works with html file extensions.
Just follow these steps to add pagination to your blog:
add the pagination setting:1
markdown: rdiscount
pygments: true
lsi: true
exclude: ['README.markdown', 'README_FOR_COLLABORATORS.markdown', 'Gemfile.lock', 'Gemfile']
production: false
//add this line to add pagination
paginate: 3 //the number of post per page
From:https://github.com/mojombo/jekyll/wiki/Usage
Creating a Jekyll site usually involves the following, [[once jekyll is installed.|Install]]
Jekyll at its core is a text transformation engine. The concept behind the system is this: you give it text written in your favorite markup language, be that Markdown, Textile, or just plain HTML, and it churns that through a layout or series of layout files. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed on the layout and more. This is all done through strictly editing files, and the web interface is the final product.
A basic Jekyll site usually looks something like this:
From:https://github.com/mojombo/jekyll/wiki/Template-Data
Jekyll traverses your site looking for files to process. Any files with [[YAML Front Matter]] are subject to processing. For each of these files, Jekyll makes a variety of data available to the pages via the “Liquid templating system”:http://wiki.github.com/shopify/liquid/liquid-for-designers. The following is a reference of the available data.
h2. Global
| Variable | Description |
| @site@ | Sitewide information + Configuration settings from @_config.yml@ |
| @page@ | This is just the [[YAML Front Matter]] with 2 additions: @url@ and @content@. |
| @content@ | In layout files, this contains the content of the subview(s). This is the variable used to insert the rendered content into the layout. This is not used in post files or page files. |
| @paginator@| When the @paginate@ configuration option is set, this variable becomes available for use. |
From:https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter
Any files that contain a “YAML”:http://yaml.org/ front matter block will be processed by Jekyll as special files. The front matter must be the first thing in the file and takes the form of:
--- layout: post title: Blogging Like a Hacker ---
Between the triple-dashed lines, you can set predefined variables (see below for a reference) or custom data of your own.
IMPORTANT! (Especially for Windows users)
When you use UTF-8
encoding for your file, make it clear that no BOM
header chars in your file. Or everything will blow up!
Jekyll是一个使用Ruby编写的静态站点生成工具,使用Liquid模板渲染引擎,支持Markdown和Textile标记语言,并且可以为所有以 .html、.markdown、.textile扩展名结尾的文件使用YAML配置,内置语法高亮功能。而Github的Pages服务可以为每个Github主机上的仓库提供静态页面服务,并且Pages服务支持Jekyll。因为Github Pages有两种Pages,分别是用户页面和项目页面,所以我们可以使用用户页面来创建自己的Blog。
在开始前,请确保你已经有了Github账号一枚和Git的正确配置。没有的朋友可以先移步Github注册并安装配置Git。
首先,创建你的 Blog 仓库 username(请确保跟你的账号名相同).github.com:
$ mkdir username.github.com $ cd username.github.com
在使用 Jekyll 构建博客的过程中,我记录下了这些常见的函数,例如循环输出文章,输出分页等
循环输出 3 篇文章
for post in site.posts limit:3 endfor
循环输出最近 3 篇
for post in site.posts offset:3 limit:3 endfor