Skip to content

Commit fce7b49

Browse files
committed
update
1 parent 12c6df5 commit fce7b49

Some content is hidden

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

47 files changed

+2262
-2
lines changed

.DS_Store

12 KB
Binary file not shown.

404.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sorry this page does not exist =(

README

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# RAINSYNC Team From SW Maestro 3rd
2+
## Member
3+
- Seungwon Kim
4+
- Taeyang Choi
5+
- Yeonjae Roh
6+
## Legendary Mentor
7+
- Kwon-Han Bae ,aka darjeeling

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
rainsync.github.com
2-
===================
1+
## References
2+
3+
### Jekyll-Bootstrap
4+
[http://jekyllbootstrap.com/usage/jekyll-quick-start.html](http://jekyllbootstrap.com/usage/jekyll-quick-start.html)

Rakefile

+308
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
require "rubygems"
2+
require 'rake'
3+
require 'yaml'
4+
require 'time'
5+
6+
SOURCE = "."
7+
CONFIG = {
8+
'version' => "0.2.13",
9+
'themes' => File.join(SOURCE, "_includes", "themes"),
10+
'layouts' => File.join(SOURCE, "_layouts"),
11+
'posts' => File.join(SOURCE, "_posts"),
12+
'post_ext' => "md",
13+
'theme_package_version' => "0.1.0"
14+
}
15+
16+
# Path configuration helper
17+
module JB
18+
class Path
19+
SOURCE = "."
20+
Paths = {
21+
:layouts => "_layouts",
22+
:themes => "_includes/themes",
23+
:theme_assets => "assets/themes",
24+
:theme_packages => "_theme_packages",
25+
:posts => "_posts"
26+
}
27+
28+
def self.base
29+
SOURCE
30+
end
31+
32+
# build a path relative to configured path settings.
33+
def self.build(path, opts = {})
34+
opts[:root] ||= SOURCE
35+
path = "#{opts[:root]}/#{Paths[path.to_sym]}/#{opts[:node]}".split("/")
36+
path.compact!
37+
File.__send__ :join, path
38+
end
39+
40+
end #Path
41+
end #JB
42+
43+
# Usage: rake post title="A Title" [date="2012-02-09"]
44+
desc "Begin a new post in #{CONFIG['posts']}"
45+
task :post do
46+
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
47+
title = ENV["title"] || "new-post"
48+
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
49+
begin
50+
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
51+
rescue Exception => e
52+
puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!"
53+
exit -1
54+
end
55+
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
56+
if File.exist?(filename)
57+
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
58+
end
59+
60+
puts "Creating new post: #{filename}"
61+
open(filename, 'w') do |post|
62+
post.puts "---"
63+
post.puts "layout: post"
64+
post.puts "title: \"#{title.gsub(/-/,' ')}\""
65+
post.puts 'description: ""'
66+
post.puts "category: "
67+
post.puts "tags: []"
68+
post.puts "---"
69+
post.puts "{% include JB/setup %}"
70+
end
71+
end # task :post
72+
73+
# Usage: rake page name="about.html"
74+
# You can also specify a sub-directory path.
75+
# If you don't specify a file extention we create an index.html at the path specified
76+
desc "Create a new page."
77+
task :page do
78+
name = ENV["name"] || "new-page.md"
79+
filename = File.join(SOURCE, "#{name}")
80+
filename = File.join(filename, "index.html") if File.extname(filename) == ""
81+
title = File.basename(filename, File.extname(filename)).gsub(/[\W\_]/, " ").gsub(/\b\w/){$&.upcase}
82+
if File.exist?(filename)
83+
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
84+
end
85+
86+
mkdir_p File.dirname(filename)
87+
puts "Creating new page: #{filename}"
88+
open(filename, 'w') do |post|
89+
post.puts "---"
90+
post.puts "layout: page"
91+
post.puts "title: \"#{title}\""
92+
post.puts 'description: ""'
93+
post.puts "---"
94+
post.puts "{% include JB/setup %}"
95+
end
96+
end # task :page
97+
98+
desc "Launch preview environment"
99+
task :preview do
100+
system "jekyll --auto --server"
101+
end # task :preview
102+
103+
# Public: Alias - Maintains backwards compatability for theme switching.
104+
task :switch_theme => "theme:switch"
105+
106+
namespace :theme do
107+
108+
# Public: Switch from one theme to another for your blog.
109+
#
110+
# name - String, Required. name of the theme you want to switch to.
111+
# The the theme must be installed into your JB framework.
112+
#
113+
# Examples
114+
#
115+
# rake theme:switch name="the-program"
116+
#
117+
# Returns Success/failure messages.
118+
desc "Switch between Jekyll-bootstrap themes."
119+
task :switch do
120+
theme_name = ENV["name"].to_s
121+
theme_path = File.join(CONFIG['themes'], theme_name)
122+
settings_file = File.join(theme_path, "settings.yml")
123+
non_layout_files = ["settings.yml"]
124+
125+
abort("rake aborted: name cannot be blank") if theme_name.empty?
126+
abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
127+
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])
128+
129+
Dir.glob("#{theme_path}/*") do |filename|
130+
next if non_layout_files.include?(File.basename(filename).downcase)
131+
puts "Generating '#{theme_name}' layout: #{File.basename(filename)}"
132+
133+
open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
134+
if File.basename(filename, ".html").downcase == "default"
135+
page.puts "---"
136+
page.puts File.read(settings_file) if File.exist?(settings_file)
137+
page.puts "---"
138+
else
139+
page.puts "---"
140+
page.puts "layout: default"
141+
page.puts "---"
142+
end
143+
page.puts "{% include JB/setup %}"
144+
page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
145+
end
146+
end
147+
148+
puts "=> Theme successfully switched!"
149+
puts "=> Reload your web-page to check it out =)"
150+
end # task :switch
151+
152+
# Public: Install a theme using the theme packager.
153+
# Version 0.1.0 simple 1:1 file matching.
154+
#
155+
# git - String, Optional path to the git repository of the theme to be installed.
156+
# name - String, Optional name of the theme you want to install.
157+
# Passing name requires that the theme package already exist.
158+
#
159+
# Examples
160+
#
161+
# rake theme:install git="https://github.com/jekyllbootstrap/theme-twitter.git"
162+
# rake theme:install name="cool-theme"
163+
#
164+
# Returns Success/failure messages.
165+
desc "Install theme"
166+
task :install do
167+
if ENV["git"]
168+
manifest = theme_from_git_url(ENV["git"])
169+
name = manifest["name"]
170+
else
171+
name = ENV["name"].to_s.downcase
172+
end
173+
174+
packaged_theme_path = JB::Path.build(:theme_packages, :node => name)
175+
176+
abort("rake aborted!
177+
=> ERROR: 'name' cannot be blank") if name.empty?
178+
abort("rake aborted!
179+
=> ERROR: '#{packaged_theme_path}' directory not found.
180+
=> Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap
181+
=> To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'`
182+
=> example : rake theme:install git='[email protected]:jekyllbootstrap/theme-the-program.git'
183+
") unless FileTest.directory?(packaged_theme_path)
184+
185+
manifest = verify_manifest(packaged_theme_path)
186+
187+
# Get relative paths to packaged theme files
188+
# Exclude directories as they'll be recursively created. Exclude meta-data files.
189+
packaged_theme_files = []
190+
FileUtils.cd(packaged_theme_path) {
191+
Dir.glob("**/*.*") { |f|
192+
next if ( FileTest.directory?(f) || f =~ /^(manifest|readme|packager)/i )
193+
packaged_theme_files << f
194+
}
195+
}
196+
197+
# Mirror each file into the framework making sure to prompt if already exists.
198+
packaged_theme_files.each do |filename|
199+
file_install_path = File.join(JB::Path.base, filename)
200+
if File.exist? file_install_path
201+
next if ask("#{file_install_path} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
202+
else
203+
mkdir_p File.dirname(file_install_path)
204+
cp_r File.join(packaged_theme_path, filename), file_install_path
205+
end
206+
end
207+
208+
puts "=> #{name} theme has been installed!"
209+
puts "=> ---"
210+
if ask("=> Want to switch themes now?", ['y', 'n']) == 'y'
211+
system("rake switch_theme name='#{name}'")
212+
end
213+
end
214+
215+
# Public: Package a theme using the theme packager.
216+
# The theme must be structured using valid JB API.
217+
# In other words packaging is essentially the reverse of installing.
218+
#
219+
# name - String, Required name of the theme you want to package.
220+
#
221+
# Examples
222+
#
223+
# rake theme:package name="twitter"
224+
#
225+
# Returns Success/failure messages.
226+
desc "Package theme"
227+
task :package do
228+
name = ENV["name"].to_s.downcase
229+
theme_path = JB::Path.build(:themes, :node => name)
230+
asset_path = JB::Path.build(:theme_assets, :node => name)
231+
232+
abort("rake aborted: name cannot be blank") if name.empty?
233+
abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
234+
abort("rake aborted: '#{asset_path}' directory not found.") unless FileTest.directory?(asset_path)
235+
236+
## Mirror theme's template directory (_includes)
237+
packaged_theme_path = JB::Path.build(:themes, :root => JB::Path.build(:theme_packages, :node => name))
238+
mkdir_p packaged_theme_path
239+
cp_r theme_path, packaged_theme_path
240+
241+
## Mirror theme's asset directory
242+
packaged_theme_assets_path = JB::Path.build(:theme_assets, :root => JB::Path.build(:theme_packages, :node => name))
243+
mkdir_p packaged_theme_assets_path
244+
cp_r asset_path, packaged_theme_assets_path
245+
246+
## Log packager version
247+
packager = {"packager" => {"version" => CONFIG["theme_package_version"].to_s } }
248+
open(JB::Path.build(:theme_packages, :node => "#{name}/packager.yml"), "w") do |page|
249+
page.puts packager.to_yaml
250+
end
251+
252+
puts "=> '#{name}' theme is packaged and available at: #{JB::Path.build(:theme_packages, :node => name)}"
253+
end
254+
255+
end # end namespace :theme
256+
257+
# Internal: Download and process a theme from a git url.
258+
# Notice we don't know the name of the theme until we look it up in the manifest.
259+
# So we'll have to change the folder name once we get the name.
260+
#
261+
# url - String, Required url to git repository.
262+
#
263+
# Returns theme manifest hash
264+
def theme_from_git_url(url)
265+
tmp_path = JB::Path.build(:theme_packages, :node => "_tmp")
266+
abort("rake aborted: system call to git clone failed") if !system("git clone #{url} #{tmp_path}")
267+
manifest = verify_manifest(tmp_path)
268+
new_path = JB::Path.build(:theme_packages, :node => manifest["name"])
269+
if File.exist?(new_path) && ask("=> #{new_path} theme package already exists. Override?", ['y', 'n']) == 'n'
270+
remove_dir(tmp_path)
271+
abort("rake aborted: '#{manifest["name"]}' already exists as theme package.")
272+
end
273+
274+
remove_dir(new_path) if File.exist?(new_path)
275+
mv(tmp_path, new_path)
276+
manifest
277+
end
278+
279+
# Internal: Process theme package manifest file.
280+
#
281+
# theme_path - String, Required. File path to theme package.
282+
#
283+
# Returns theme manifest hash
284+
def verify_manifest(theme_path)
285+
manifest_path = File.join(theme_path, "manifest.yml")
286+
manifest_file = File.open( manifest_path )
287+
abort("rake aborted: repo must contain valid manifest.yml") unless File.exist? manifest_file
288+
manifest = YAML.load( manifest_file )
289+
manifest_file.close
290+
manifest
291+
end
292+
293+
def ask(message, valid_options)
294+
if valid_options
295+
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
296+
else
297+
answer = get_stdin(message)
298+
end
299+
answer
300+
end
301+
302+
def get_stdin(message)
303+
print message
304+
STDIN.gets.chomp
305+
end
306+
307+
#Load custom rake scripts
308+
Dir['_rake/*.rake'].each { |r| load r }

0 commit comments

Comments
 (0)