Skip to content

Commit b5298ef

Browse files
committed
initialize repository
1 parent 51a8858 commit b5298ef

File tree

228 files changed

+11389
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+11389
-1
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
_site/*
2+
3+
Thumbs.db
4+
.DS_Store
5+
6+
!.gitkeep
7+
8+
.rbenv-version
9+
.rvmrc

404.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
对不起,该页面不存在!
2+
Sorry this page does not exist

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9932.js.org

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# dannyzhan.github.io
1+
# 刀儿博客
2+
3+
记录刀儿的生活点滴
4+
5+
6+
## License
7+
8+
[Creative Commons](http://creativecommons.org/licenses/by-nc-sa/3.0/)

Rakefile

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
require "rubygems"
2+
require 'rake'
3+
4+
SOURCE = "."
5+
CONFIG = {
6+
'themes' => File.join(SOURCE, "_includes", "themes"),
7+
'layouts' => File.join(SOURCE, "_layouts"),
8+
'posts' => File.join(SOURCE, "_posts"),
9+
'post_ext' => "md"
10+
}
11+
12+
# Usage: rake post title="A Title"
13+
desc "Begin a new post in #{CONFIG['posts']}"
14+
task :post do
15+
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
16+
title = ENV["title"] || "new-post"
17+
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
18+
filename = File.join(CONFIG['posts'], "#{Time.now.strftime('%Y-%m-%d')}-#{slug}.#{CONFIG['post_ext']}")
19+
if File.exist?(filename)
20+
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
21+
end
22+
23+
puts "Creating new post: #{filename}"
24+
open(filename, 'w') do |post|
25+
post.puts "---"
26+
post.puts "layout: post"
27+
post.puts "title: \"#{title.gsub(/-/,' ')}\""
28+
post.puts "category: "
29+
post.puts "tags: []"
30+
post.puts "---"
31+
post.puts "{% include JB/setup %}"
32+
end
33+
end # task :post
34+
35+
# Usage: rake page name="about.html"
36+
# You can also specify a sub-directory path.
37+
# If you don't specify a file extention we create an index.html at the path specified
38+
desc "Create a new page."
39+
task :page do
40+
name = ENV["name"] || "new-page.md"
41+
filename = File.join(SOURCE, "#{name}")
42+
filename = File.join(filename, "index.html") if File.extname(filename) == ""
43+
title = File.basename(filename, File.extname(filename)).gsub(/[\W\_]/, " ").gsub(/\b\w/){$&.upcase}
44+
if File.exist?(filename)
45+
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
46+
end
47+
48+
mkdir_p File.dirname(filename)
49+
puts "Creating new page: #{filename}"
50+
open(filename, 'w') do |post|
51+
post.puts "---"
52+
post.puts "layout: page"
53+
post.puts "title: \"#{title}\""
54+
post.puts "---"
55+
post.puts "{% include JB/setup %}"
56+
end
57+
end # task :page
58+
59+
desc "Switch between Jekyll-bootstrap themes."
60+
task :switch_theme do
61+
theme_name = ENV["name"].to_s
62+
theme_path = File.join(CONFIG['themes'], theme_name)
63+
settings_file = File.join(theme_path, "settings.yml")
64+
non_layout_files = ["settings.yml"]
65+
66+
abort("rake aborted: name cannot be blank") if theme_name.empty?
67+
abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
68+
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])
69+
70+
Dir.glob("#{theme_path}/*") do |filename|
71+
next if non_layout_files.include?(File.basename(filename).downcase)
72+
puts "Generating '#{theme_name}' layout: #{File.basename(filename)}"
73+
74+
open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
75+
if File.basename(filename, ".html").downcase == "default"
76+
page.puts "---"
77+
page.puts File.read(settings_file) if File.exist?(settings_file)
78+
page.puts "---"
79+
else
80+
page.puts "---"
81+
page.puts "layout: default"
82+
page.puts "---"
83+
end
84+
page.puts "{% include JB/setup %}"
85+
page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
86+
end
87+
end
88+
end # task :switch_theme
89+
90+
desc "Launch preview environment"
91+
task :preview do
92+
system "jekyll --auto --server"
93+
end # task :preview
94+
95+
def ask(message, valid_options)
96+
if valid_options
97+
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
98+
else
99+
answer = get_stdin(message)
100+
end
101+
answer
102+
end
103+
104+
def get_stdin(message)
105+
print message
106+
STDIN.gets.chomp
107+
end

_config.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# This is the default format.
2+
# For more see: https://github.com/mojombo/jekyll/wiki/Permalinks
3+
permalink: /:year/:month/:day/:title
4+
5+
exclude: [".rbenv-version", "README.md", "Rakefile"]
6+
auto: true
7+
markdown: kramdown
8+
highlighter: rouge
9+
10+
# Themes are encouraged to use these universal variables
11+
# so be sure to set them if your theme uses them.
12+
#
13+
title : Danny Zhan
14+
tagline: "aka naoki, david"
15+
author :
16+
name : Danny Zhan
17+
18+
github : dannyzhan
19+
twitter : dannyzhan
20+
feedburner : dannyzhan001
21+
22+
23+
# Theme settings
24+
theme:
25+
# Google analytics UID
26+
google_analytics_uid: UA-140337377-1
27+
# Disqus shortname, for comments
28+
disqus_shortname: dannyzhan
29+
# Number of featured posts on homepage
30+
homepage_featured: 1
31+
# Number of posts on homepage (in addition to featured posts)
32+
homepage_posts: 3
33+
# Number of words to display in post summaries
34+
featured_wordcount: 120
35+
36+
# The production_url is only used when full-domain names are needed
37+
# such as sitemap.txt
38+
# Most places will/should use BASE_PATH to make the urls
39+
#
40+
# If you have set a CNAME (pages.github.com) set your custom domain here.
41+
# Else if you are pushing to username.github.com, replace with your username.
42+
# Finally if you are pushing to a GitHub project page, include the project name at the end.
43+
#
44+
production_url : https://9932.js.org
45+
46+
# All Jekyll-Bootstrap specific configurations are namespaced into this hash
47+
#
48+
JB :
49+
version : 0.1.0
50+
51+
# All links will be namespaced by BASE_PATH if defined.
52+
# This is required for hosting GitHub Project Pages.
53+
# If you are deploying this website for one of your GitHub projects
54+
# you must set BASE_PATH to the name of your GitHub project.
55+
#
56+
# Leave this blank if you have defined a CNAME for your site (pages.github.com)
57+
# NOTE: When in localhost, your site will run from root "/" regardless of BASE_PATH
58+
#
59+
BASE_PATH : ""
60+
61+
# By default, the asset_path is automatically defined relative to BASE_PATH plus the enabled theme.
62+
# ex: [BASE_PATH]/assets/themes/[THEME-NAME]
63+
#
64+
# Override this by defining an absolute path to assets here.
65+
# ex:
66+
# http://s3.amazonaws.com/yoursite/themes/watermelon
67+
# /assets
68+
#
69+
ASSET_PATH : false
70+
71+
# These paths are to the main pages Jekyll-Bootstrap ships with.
72+
# Some JB helpers refer to these paths; change theme here if needed.
73+
#
74+
archive_path: /archive/
75+
categories_path : /categories/
76+
tags_path : /tag/
77+
78+
# Settings for comments helper
79+
# Set 'provider' to the comment provider you want to use.
80+
# Set 'provider' to false to turn commenting off globally.
81+
#
82+
comments :
83+
provider : disqus
84+
disqus :
85+
short_name : dannyzhan
86+
livefyre :
87+
site_id : 123
88+
intensedebate :
89+
account : 123abc
90+
facebook :
91+
apikey : 123
92+
93+
# Settings for analytics helper
94+
# Set 'provider' to the analytics provider you want to use.
95+
# Set 'provider' to false to turn analytics off globally.
96+
#
97+
analytics :
98+
provider : google
99+
google :
100+
tracking_id : 'UA-140337377-1'
101+
getclicky :
102+
site_id :
103+
104+
# Settings for sharing helper.
105+
# Sharing is for things like tweet, plusone, like, reddit buttons etc.
106+
# Set 'provider' to the sharing provider you want to use.
107+
# Set 'provider' to false to turn sharing off globally.
108+
#
109+
sharing :
110+
provider : false
111+
112+
# Settings for all other include helpers can be defined by creating
113+
# a hash with key named for the given helper. ex:
114+
#
115+
# pages_list :
116+
# provider : "custom"
117+
#
118+
# Setting any helper's provider to 'custom' will bypass the helper code
119+
# and include your custom code. Your custom file must be defined at:
120+
# ./_includes/custom/[HELPER]
121+
# where [HELPER] is the name of the helper you are overriding.
122+

_import/wordpress.rb

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
require 'rubygems'
2+
require 'sequel'
3+
require 'fileutils'
4+
require 'yaml'
5+
6+
# NOTE: This converter requires Sequel and the MySQL gems.
7+
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
8+
# installed, running the following commands should work:
9+
# $ sudo gem install sequel
10+
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
11+
12+
module Jekyll
13+
module WordPress
14+
def self.process(dbname, user, pass, host = 'localhost', table_prefix = 'wp_')
15+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
16+
17+
FileUtils.mkdir_p("_posts")
18+
19+
# Reads a MySQL database via Sequel and creates a post file for each
20+
# post in wp_posts that has post_status = 'publish'. This restriction is
21+
# made because 'draft' posts are not guaranteed to have valid dates.
22+
query = "SELECT post_title, \
23+
post_name, \
24+
post_date, \
25+
post_content, \
26+
post_excerpt, \
27+
ID, \
28+
guid \
29+
FROM #{table_prefix}posts \
30+
WHERE post_status = 'publish' AND \
31+
post_type = 'post'"
32+
33+
db[query].each do |post|
34+
# Get required fields and construct Jekyll compatible name.
35+
title = post[:post_title]
36+
slug = post[:post_name]
37+
date = post[:post_date]
38+
content = post[:post_content]
39+
name = "%02d-%02d-%02d-%s.md" % [date.year, date.month, date.day,
40+
slug]
41+
42+
# Get the relevant fields as a hash, delete empty fields and convert
43+
# to YAML for the header.
44+
data = {
45+
'layout' => 'post',
46+
'title' => title.to_s,
47+
'excerpt' => post[:post_excerpt].to_s,
48+
'wordpress_id' => post[:ID],
49+
'wordpress_url' => post[:guid],
50+
'date' => date
51+
}.delete_if { |k,v| v.nil? || v == '' }.to_yaml
52+
53+
# Write out the data and content to file
54+
File.open("_posts/#{name}", "w") do |f|
55+
f.puts data
56+
f.puts "---"
57+
f.puts content
58+
end
59+
end
60+
end
61+
end
62+
end

_includes/JB/analytics

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% if site.safe and site.JB.analytics.provider and page.JB.analytics != false %}
2+
3+
{% case site.JB.analytics.provider %}
4+
{% when "google" %}
5+
{% include JB/analytics-providers/google %}
6+
{% when "getclicky" %}
7+
{% include JB/analytics-providers/getclicky %}
8+
{% when "custom" %}
9+
{% include custom/analytics %}
10+
{% endcase %}
11+
12+
{% endif %}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script type="text/javascript">
2+
var clicky_site_ids = clicky_site_ids || [];
3+
clicky_site_ids.push({{ site.JB.analytics.getclicky.site_id }});
4+
(function() {
5+
var s = document.createElement('script');
6+
s.type = 'text/javascript';
7+
s.async = true;
8+
s.src = '//static.getclicky.com/js';
9+
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
10+
})();
11+
</script>
12+
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/66527741ns.gif" /></p></noscript>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script type="text/javascript">
2+
var _gaq = _gaq || [];
3+
_gaq.push(['_setAccount', '{{ site.JB.analytics.google.tracking_id }}']);
4+
_gaq.push(['_trackPageview']);
5+
6+
(function() {
7+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
8+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
9+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
10+
})();
11+
</script>

0 commit comments

Comments
 (0)