Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jekyll Bootstrap version of the website #4

Merged
merged 187 commits into from
Apr 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
4c18e3c
version 0.0.1
plusjade Dec 30, 2011
486d099
add .rbenv-version
studiomohawk Jan 12, 2012
223a9ca
add rake preview for development
studiomohawk Jan 12, 2012
dc6bc0d
add feedbuner url
studiomohawk Jan 12, 2012
66a3d56
the_minimum theme is ready
studiomohawk Jan 12, 2012
ab03c6d
sample content updates
plusjade Jan 12, 2012
3b239b9
specify page group 'navigation'
plusjade Jan 12, 2012
2e16fad
add little arrow to collated list
plusjade Jan 12, 2012
46c738c
assign active class to li
plusjade Jan 12, 2012
3a6ba2d
add twitter bootstrap theme
plusjade Jan 12, 2012
72f5694
use twitter theme as default
plusjade Jan 12, 2012
4021a8c
title should not have changed
studiomohawk Jan 12, 2012
7758988
remove linear class
studiomohawk Jan 13, 2012
320470d
remove linear class
studiomohawk Jan 13, 2012
0ec3a40
missing ul tags
studiomohawk Jan 13, 2012
4da313a
Fixed minor issues
studiomohawk Jan 13, 2012
4bcfd7a
add more detail
studiomohawk Jan 13, 2012
5abba31
sample content updates
plusjade Jan 12, 2012
ef17645
specify page group 'navigation'
plusjade Jan 12, 2012
2383611
add little arrow to collated list
plusjade Jan 12, 2012
eca5de0
assign active class to li
plusjade Jan 12, 2012
4aadec2
add twitter bootstrap theme
plusjade Jan 12, 2012
e34311d
use twitter theme as default
plusjade Jan 12, 2012
a760814
fix merge conflict
plusjade Jan 13, 2012
812e27b
Add Atom rss feeds
Jan 15, 2012
f3f08f9
Merge pull request #8 from swanson/master
plusjade Jan 15, 2012
6ee3125
adding the new_post task, with bugs fixed which were pointed out by @…
pradeep1288 Jan 16, 2012
6e70fdd
Change directory tests in switch_theme task to use FileTest.directory…
jcn Jan 17, 2012
e26b5f7
Merge pull request #12 from jcn/patch-1
plusjade Jan 18, 2012
246e91a
Merge pull request #11 from pradeep1288/master
plusjade Jan 18, 2012
9d7d4eb
reorganize rakefile
plusjade Jan 18, 2012
2a5c275
Hello world
plusjade Jan 19, 2012
bbf4212
Add atom title and inline tag list
plusjade Jan 19, 2012
e70aa41
remove samples
plusjade Jan 19, 2012
07eb4d1
don't process rakefile, readme
plusjade Jan 19, 2012
80595af
fixed incorrect link to jekyll bootstrap homepage
jogjayr Jan 19, 2012
df13158
Merge pull request #13 from jogjayr/master
plusjade Jan 19, 2012
bb8ec4c
Fixed typo: title should be "Jekyll Bootstrap"
xtine Jan 20, 2012
dad96fb
Merge pull request #16 from xtine/patch-1
plusjade Jan 20, 2012
5efb722
fixed broken link for jekyll quick start on index.md. checked and mad…
jogjayr Jan 21, 2012
b7a353c
Merge pull request #18 from jogjayr/master
plusjade Jan 21, 2012
3802b6c
Merge remote-tracking branch 'origin/master'
plusjade Jan 21, 2012
241a512
fix typo
plusjade Jan 21, 2012
7a0b1ed
Add new Integration points for themes
plusjade Jan 21, 2012
df5bedb
Add JB configuration hash to site config
plusjade Jan 21, 2012
45b894f
Update themes to use new integration methods
plusjade Jan 21, 2012
61cdb7a
Themes can define configuration data
plusjade Jan 21, 2012
75fa188
Add ability to dynamically set url paths
plusjade Jan 22, 2012
fe33e51
Provide set_paths to all layouts
plusjade Jan 22, 2012
3f7fd7b
Provide path configuration in _config.yml
plusjade Jan 22, 2012
71278b8
Need to provide theme name via settings.yml
plusjade Jan 22, 2012
b01624b
Update themes and pages to new paths api
plusjade Jan 22, 2012
779afdd
Regenerate 'twitter' theme
plusjade Jan 22, 2012
7ef7288
Rename set_paths to more generic 'setup'
plusjade Jan 23, 2012
a1a7efa
Include 'JB/setup' in all posts and pages
plusjade Jan 23, 2012
0fec345
rename HOME_URL to HOME_PATH
plusjade Jan 23, 2012
f52ff5a
Refactor new post rake task
plusjade Jan 23, 2012
6d0e38b
Add rake task to create pages
plusjade Jan 23, 2012
8b79986
Move helpers to namespaced system
plusjade Jan 23, 2012
5c0a7a6
Update helper calls
plusjade Jan 23, 2012
08d59a6
Remove all filename extenstions from JB files
plusjade Jan 23, 2012
6c0b6c1
Provide custom overrides to all helpers
plusjade Jan 23, 2012
3f0579c
Place paths to main pages in JB hash
plusjade Jan 23, 2012
9b3a325
Document and reorganize _config.yml
plusjade Jan 23, 2012
2402716
production url should be close to JB
plusjade Jan 23, 2012
9bd0dea
Use ENV variables for switch_theme
plusjade Jan 24, 2012
065e6ed
'Provider' is more correct than 'engine'
plusjade Jan 24, 2012
c197237
version 0.1.0
plusjade Jan 24, 2012
266475e
Remove BASE_PATH setting
plusjade Jan 24, 2012
9ba7f1b
Adding a site-wide configuration option for tagline. The twitter them…
SegFaultAX Jan 30, 2012
e99e752
Merge pull request #25 from SegFaultAX/tagline-option
plusjade Jan 30, 2012
683d1be
Adding Facebook Comments
fleeting Jan 31, 2012
53a801b
Implement theme installer v 0.1.0
plusjade Feb 1, 2012
21b64c2
Update theme packager methods
plusjade Feb 1, 2012
d25b40e
don't track _theme_packages directory
plusjade Feb 1, 2012
533d840
Namespace 'switch_theme'
plusjade Feb 1, 2012
fdfb9c4
Fix prompt complaining that directories already exist
plusjade Feb 2, 2012
5b2cc52
Themes are tracked and installed via the packager.
plusjade Feb 2, 2012
a86349e
Add changelog
plusjade Feb 2, 2012
58fa445
update contributing instructions
plusjade Feb 2, 2012
4c29c7e
bump version : 0.2.0
plusjade Feb 4, 2012
1580fb2
fix clicky tracking image
sdball Feb 4, 2012
eb40808
Merge pull request #29 from sdball/fix_getclicky_code
plusjade Feb 4, 2012
7a799ce
index.md: add tagline metadata
philips Feb 5, 2012
4a4a4a8
Loading custom rake file from _rake/*.rake
nolith Feb 6, 2012
3a2df76
Resolve incorrect HOME_PATH/BASE_PATH settings
plusjade Feb 6, 2012
068e522
Added error check for git clone system call.
vattay Feb 8, 2012
9bb6ea1
Small fix to check the correct variable (page.comments instead of pag…
sstarr Feb 19, 2012
ba5fa9b
Issue #46, theme install fails on msys, permissions.
vattay Feb 23, 2012
4a03980
Improved error text.
vattay Feb 23, 2012
7956efe
Added the wordpress_id value in Disqus code if present in the post
tommyblue Feb 25, 2012
878e06c
Merge pull request #47 from tommyblue/jb-development
plusjade Feb 25, 2012
af88390
Adding Mixpanel as analytics provider
koomar Feb 29, 2012
309a6f4
Update to bootstrap 2.0.1
daz Mar 1, 2012
c031df4
Merge pull request #44 from sstarr/patch-1
plusjade Mar 1, 2012
f9b9cff
Setting google as default analytics provider
koomar Mar 1, 2012
535aa3d
Merge remote-tracking branch 'nolith/custom-rake' into jb-development…
plusjade Mar 1, 2012
ca37b93
Merge pull request #40 from 3martini/windows-topic
plusjade Mar 1, 2012
b804d16
Merge pull request #49 from koomar/jb-development
plusjade Mar 1, 2012
76d3a97
Merge remote-tracking branch 'daz/master' into jb-development. issue #50
plusjade Mar 1, 2012
beb45da
Merge remote-tracking branch 'philips/tagline-metadata' into jb-devel…
plusjade Mar 1, 2012
12e4175
bump to 0.2.7
plusjade Mar 1, 2012
02e2f86
Added option to specify time when creating posts
Feb 8, 2012
2d629f2
Using Time.parse to ensure date format is valid
Feb 13, 2012
1a9411a
Forgot including require time
Feb 13, 2012
9c1cf75
Added exception handling to display a user friendly message when time…
Feb 13, 2012
cefdd4e
bump to 0.2.8
plusjade Mar 1, 2012
9a69c8e
Fix for the error on post creation if date was not specified.
alishutc Mar 7, 2012
6d97712
Fix typo
plusjade Mar 7, 2012
162a85d
Bump to 0.2.9
plusjade Mar 7, 2012
59d6a7b
fixed extra h hanging out in atomfeed ids #60
koriroys Mar 11, 2012
1aa9527
Added the description-variable in the Rakefile to include it in newly…
LukasKnuth Mar 20, 2012
cc7a99f
styling
plusjade Mar 24, 2012
e3e849e
Show tagline only if set. credit to @sway as seen in pull #48
plusjade Mar 24, 2012
cbfb9ca
Only list pages with a title. #69
mjpieters Mar 23, 2012
9c00269
bump to 0.2.13
plusjade Mar 24, 2012
93e0c46
update to post template on twitter theme: added dynamic page description
lzcabrera Apr 2, 2012
b74f290
added dynamic tagline to posts and conditional display statement on p…
lzcabrera Apr 2, 2012
d0e9992
Fixed a malformed date in the sample post.
Apr 6, 2012
5af2512
Fix that theme will not be overwritten if exists.
xuhdev Apr 16, 2012
10add52
Giving every post/page the "smarter" custom tagline (just like page.h…
Aug 8, 2012
a6f699c
Adds Piwik Analytics Provider
rsertelon Sep 11, 2012
aeac709
Update 'rake post' to support tags on command line
opie4624 Sep 17, 2012
f2b4639
Update _config.yml
lorensr Oct 18, 2012
fecaedc
Fixed a typo in _config.yml
robot-c0der Jan 1, 2013
c06cbf3
Merge pull request #122 from awkerney/master
plusjade Jan 2, 2013
c87f664
Display current year via javascript
djoos Jan 7, 2013
df99e39
jekyll current time (when you run the jekyll command)
djoos Jan 29, 2013
c676106
Merge pull request #123 from djoos/master
plusjade Jan 29, 2013
5a77785
Make it responsive out of the gate
jkuchta Feb 23, 2013
fcff62c
Merge pull request #132 from jkuchta/master
plusjade Feb 24, 2013
4039de7
Merge pull request #74 from lzcabrera/post_update
plusjade Feb 24, 2013
ef0d8a0
Merge pull request #110 from lorensr/patch-1
plusjade Feb 24, 2013
c84ac28
Merge pull request #102 from techotaku/jb-development
plusjade Feb 24, 2013
2001b5c
Fix merge conflict.
plusjade Feb 24, 2013
1cd2592
Merge pull request #77 from geon/master
plusjade Feb 24, 2013
0f00bf5
Merge pull request #81 from xuhdev/fix-theme-install
plusjade Feb 24, 2013
4d45997
update twitter bootstrap css and png's to version 2.1.1
Oct 16, 2012
afec1ee
add support for RSS feed.
Lax Feb 13, 2013
29eae1f
Upgrade to twitter bootstrap 2.2.2 plus new styling.
plusjade Feb 24, 2013
aa605b9
License should be MIT.
plusjade Feb 24, 2013
8dc291a
Reformat copyright notice as per advice from @allolex.
plusjade Feb 24, 2013
0dde354
Merge pull request #107 from opie4624/patch-1
plusjade Feb 24, 2013
d82396e
Merge remote-tracking branch 'origin/master'
plusjade Feb 24, 2013
77fc4c0
release 0.3.0
plusjade Feb 24, 2013
c95468a
Update config to use new github domain
pierredup Apr 19, 2013
7c748b6
Fix incorrect tag
pierredup Apr 19, 2013
df13170
Merge pull request #145 from pierredup/patch-1
plusjade Apr 19, 2013
c8038ab
Merge pull request #146 from pierredup/patch-2
plusjade Apr 19, 2013
7b88b02
Better exception handling
danielfone May 19, 2013
8e43db2
Merge pull request #159 from danielfone/patch-1
subosito Jun 7, 2013
2c98321
Merge pull request #106 from BluePyth/piwik_provider
subosito Jun 8, 2013
a08b59d
add mission
Jul 23, 2013
b451b2a
add draft feature
Jul 24, 2013
0766ee2
Fix incorrect tag
pierredup Apr 19, 2013
ff69d3f
Better exception handling
danielfone May 19, 2013
2da62d4
Adds Piwik Analytics Provider
rsertelon Sep 11, 2012
c2d70e5
add draft feature
Jul 24, 2013
7501cf3
Merge add-drafts. closes #167
plusjade Jul 27, 2013
cd50618
add History markdown
Aug 6, 2013
8507c4c
Merge branch 'master' of github.com:plusjade/jekyll-bootstrap into cr…
Aug 6, 2013
50aa9b6
Fixed outdated link
markijbema Aug 10, 2013
d25c492
Merge pull request #170 from markijbema/patch-1
marshallshen Aug 14, 2013
46f4a26
Merge pull request #169 from marshallshen/create_markdown
marshallshen Aug 14, 2013
af9c45d
[FIX] Fix tags output in :post task
coding46 Aug 15, 2013
4a934b0
[FIX] Fixed small typo in comment
coding46 Aug 15, 2013
f667a9b
Merge pull request #172 from coding46/patch-2
plusjade Aug 15, 2013
010d99f
Merge pull request #171 from coding46/patch-1
plusjade Aug 15, 2013
28c3ba7
Updated Rakefile :preview command to new Jekyll standards
kvannotten Aug 31, 2013
dbdf47a
Updated _config.yml => removed auto property, deprecated in the lates…
kvannotten Sep 3, 2013
dea31e7
Merge pull request #179 from kvannotten/patch-1
marshallshen Sep 4, 2013
fed94a2
Update History.markdown
marshallshen Sep 4, 2013
56bc767
Update 'rake post' to support category on command line
Miguelos Sep 7, 2013
89530f6
Merge pull request #183 from Miguelos/patch-2
marshallshen Sep 23, 2013
ee1d6b1
fix parsing error
Oct 9, 2013
10b4ad0
Merge pull request #189 from marshallshen/master
marshallshen Oct 9, 2013
2f6c40b
Update readme to point to new separate documentation repository.
plusjade Oct 18, 2013
2fc2e06
Remove empty quotes when category is empty.
parnmatt Jan 1, 2014
a53b4a9
Simpler logic to category patch
parnmatt Jan 1, 2014
6c4bbd9
Merge pull request #198 from parnmatt/patch-1
marshallshen Jan 2, 2014
75b86d5
Merge branch 'master' of github.com:sigint-ctf/sigint-ctf.github.io i…
jakemask Apr 6, 2014
ba9d609
removed dummy index
jakemask Apr 6, 2014
897b0cd
made things sigint specific
jakemask Apr 8, 2014
4d3111c
added backdoor2014 writeup
jakemask Apr 8, 2014
a132413
Added nuitduhack2014 writeups
jakemask Apr 8, 2014
f5673a8
small fixes
jakemask Apr 8, 2014
b5f1aa1
added volga2014 writeups
jakemask Apr 8, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_site/*
_theme_packages/*

Thumbs.db
.DS_Store

!.gitkeep

.rbenv-version
.rvmrc
*.swp
1 change: 1 addition & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sorry this page does not exist =(
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Jekyll-Bootstrap

The quickest way to start and publish your Jekyll powered blog. 100% compatible with GitHub pages

## Usage

For all usage and documentation please see: <http://jekyllbootstrap.com>

## Version

0.3.0 - stable and versioned using [semantic versioning](http://semver.org/).

**NOTE:** 0.3.0 introduces a new theme which is not backwards compatible in the sense it won't _look_ like the old version.
However, the actual API has not changed at all.
You might want to run 0.3.0 in a branch to make sure you are ok with the theme design changes.

## Contributing


To contribute to the framework please make sure to checkout your branch based on `jb-development`!!
This is very important as it allows me to accept your pull request without having to publish a public version release.

Small, atomic Features, bugs, etc.
Use the `jb-development` branch but note it will likely change fast as pull requests are accepted.
Please rebase as often as possible when working.
Work on small, atomic features/bugs to avoid upstream commits affecting/breaking your development work.

For Big Features or major API extensions/edits:
This is the one case where I'll accept pull-requests based off the master branch.
This allows you to work in isolation but it means I'll have to manually merge your work into the next public release.
Translation : it might take a bit longer so please be patient! (but sincerely thank you).

**Jekyll-Bootstrap Documentation Website.**

The documentation website at <http://jekyllbootstrap.com> is maintained at https://github.com/plusjade/jekyllbootstrap.com


## License

[MIT](http://opensource.org/licenses/MIT)
311 changes: 311 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
require "rubygems"
require 'rake'
require 'yaml'
require 'time'

SOURCE = "."
CONFIG = {
'version' => "0.3.0",
'themes' => File.join(SOURCE, "_includes", "themes"),
'layouts' => File.join(SOURCE, "_layouts"),
'posts' => File.join(SOURCE, "_posts"),
'post_ext' => "md",
'theme_package_version' => "0.1.0"
}

# Path configuration helper
module JB
class Path
SOURCE = "."
Paths = {
:layouts => "_layouts",
:themes => "_includes/themes",
:theme_assets => "assets/themes",
:theme_packages => "_theme_packages",
:posts => "_posts"
}

def self.base
SOURCE
end

# build a path relative to configured path settings.
def self.build(path, opts = {})
opts[:root] ||= SOURCE
path = "#{opts[:root]}/#{Paths[path.to_sym]}/#{opts[:node]}".split("/")
path.compact!
File.__send__ :join, path
end

end #Path
end #JB

# Usage: rake post title="A Title" [date="2012-02-09"] [tags=[tag1,tag2]] [category="category"]
desc "Begin a new post in #{CONFIG['posts']}"
task :post do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "new-post"
tags = ENV["tags"] || "[]"
category = ENV["category"] || ""
category = "\"#{category.gsub(/-/,' ')}\"" if !category.empty?
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
begin
date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
rescue => e
puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!"
exit -1
end
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end

puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/-/,' ')}\""
post.puts 'description: ""'
post.puts "category: #{category}"
post.puts "tags: #{tags}"
post.puts "---"
post.puts "{% include JB/setup %}"
end
end # task :post

# Usage: rake page name="about.html"
# You can also specify a sub-directory path.
# If you don't specify a file extention we create an index.html at the path specified
desc "Create a new page."
task :page do
name = ENV["name"] || "new-page.md"
filename = File.join(SOURCE, "#{name}")
filename = File.join(filename, "index.html") if File.extname(filename) == ""
title = File.basename(filename, File.extname(filename)).gsub(/[\W\_]/, " ").gsub(/\b\w/){$&.upcase}
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end

mkdir_p File.dirname(filename)
puts "Creating new page: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: page"
post.puts "title: \"#{title}\""
post.puts 'description: ""'
post.puts "---"
post.puts "{% include JB/setup %}"
end
end # task :page

desc "Launch preview environment"
task :preview do
system "jekyll serve -w"
end # task :preview

# Public: Alias - Maintains backwards compatability for theme switching.
task :switch_theme => "theme:switch"

namespace :theme do

# Public: Switch from one theme to another for your blog.
#
# name - String, Required. name of the theme you want to switch to.
# The theme must be installed into your JB framework.
#
# Examples
#
# rake theme:switch name="the-program"
#
# Returns Success/failure messages.
desc "Switch between Jekyll-bootstrap themes."
task :switch do
theme_name = ENV["name"].to_s
theme_path = File.join(CONFIG['themes'], theme_name)
settings_file = File.join(theme_path, "settings.yml")
non_layout_files = ["settings.yml"]

abort("rake aborted: name cannot be blank") if theme_name.empty?
abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])

Dir.glob("#{theme_path}/*") do |filename|
next if non_layout_files.include?(File.basename(filename).downcase)
puts "Generating '#{theme_name}' layout: #{File.basename(filename)}"

open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
if File.basename(filename, ".html").downcase == "default"
page.puts "---"
page.puts File.read(settings_file) if File.exist?(settings_file)
page.puts "---"
else
page.puts "---"
page.puts "layout: default"
page.puts "---"
end
page.puts "{% include JB/setup %}"
page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
end
end

puts "=> Theme successfully switched!"
puts "=> Reload your web-page to check it out =)"
end # task :switch

# Public: Install a theme using the theme packager.
# Version 0.1.0 simple 1:1 file matching.
#
# git - String, Optional path to the git repository of the theme to be installed.
# name - String, Optional name of the theme you want to install.
# Passing name requires that the theme package already exist.
#
# Examples
#
# rake theme:install git="https://github.com/jekyllbootstrap/theme-twitter.git"
# rake theme:install name="cool-theme"
#
# Returns Success/failure messages.
desc "Install theme"
task :install do
if ENV["git"]
manifest = theme_from_git_url(ENV["git"])
name = manifest["name"]
else
name = ENV["name"].to_s.downcase
end

packaged_theme_path = JB::Path.build(:theme_packages, :node => name)

abort("rake aborted!
=> ERROR: 'name' cannot be blank") if name.empty?
abort("rake aborted!
=> ERROR: '#{packaged_theme_path}' directory not found.
=> Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap
=> To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'`
=> example : rake theme:install git='[email protected]:jekyllbootstrap/theme-the-program.git'
") unless FileTest.directory?(packaged_theme_path)

manifest = verify_manifest(packaged_theme_path)

# Get relative paths to packaged theme files
# Exclude directories as they'll be recursively created. Exclude meta-data files.
packaged_theme_files = []
FileUtils.cd(packaged_theme_path) {
Dir.glob("**/*.*") { |f|
next if ( FileTest.directory?(f) || f =~ /^(manifest|readme|packager)/i )
packaged_theme_files << f
}
}

# Mirror each file into the framework making sure to prompt if already exists.
packaged_theme_files.each do |filename|
file_install_path = File.join(JB::Path.base, filename)
if File.exist? file_install_path and ask("#{file_install_path} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
next
else
mkdir_p File.dirname(file_install_path)
cp_r File.join(packaged_theme_path, filename), file_install_path
end
end

puts "=> #{name} theme has been installed!"
puts "=> ---"
if ask("=> Want to switch themes now?", ['y', 'n']) == 'y'
system("rake switch_theme name='#{name}'")
end
end

# Public: Package a theme using the theme packager.
# The theme must be structured using valid JB API.
# In other words packaging is essentially the reverse of installing.
#
# name - String, Required name of the theme you want to package.
#
# Examples
#
# rake theme:package name="twitter"
#
# Returns Success/failure messages.
desc "Package theme"
task :package do
name = ENV["name"].to_s.downcase
theme_path = JB::Path.build(:themes, :node => name)
asset_path = JB::Path.build(:theme_assets, :node => name)

abort("rake aborted: name cannot be blank") if name.empty?
abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
abort("rake aborted: '#{asset_path}' directory not found.") unless FileTest.directory?(asset_path)

## Mirror theme's template directory (_includes)
packaged_theme_path = JB::Path.build(:themes, :root => JB::Path.build(:theme_packages, :node => name))
mkdir_p packaged_theme_path
cp_r theme_path, packaged_theme_path

## Mirror theme's asset directory
packaged_theme_assets_path = JB::Path.build(:theme_assets, :root => JB::Path.build(:theme_packages, :node => name))
mkdir_p packaged_theme_assets_path
cp_r asset_path, packaged_theme_assets_path

## Log packager version
packager = {"packager" => {"version" => CONFIG["theme_package_version"].to_s } }
open(JB::Path.build(:theme_packages, :node => "#{name}/packager.yml"), "w") do |page|
page.puts packager.to_yaml
end

puts "=> '#{name}' theme is packaged and available at: #{JB::Path.build(:theme_packages, :node => name)}"
end

end # end namespace :theme

# Internal: Download and process a theme from a git url.
# Notice we don't know the name of the theme until we look it up in the manifest.
# So we'll have to change the folder name once we get the name.
#
# url - String, Required url to git repository.
#
# Returns theme manifest hash
def theme_from_git_url(url)
tmp_path = JB::Path.build(:theme_packages, :node => "_tmp")
abort("rake aborted: system call to git clone failed") if !system("git clone #{url} #{tmp_path}")
manifest = verify_manifest(tmp_path)
new_path = JB::Path.build(:theme_packages, :node => manifest["name"])
if File.exist?(new_path) && ask("=> #{new_path} theme package already exists. Override?", ['y', 'n']) == 'n'
remove_dir(tmp_path)
abort("rake aborted: '#{manifest["name"]}' already exists as theme package.")
end

remove_dir(new_path) if File.exist?(new_path)
mv(tmp_path, new_path)
manifest
end

# Internal: Process theme package manifest file.
#
# theme_path - String, Required. File path to theme package.
#
# Returns theme manifest hash
def verify_manifest(theme_path)
manifest_path = File.join(theme_path, "manifest.yml")
manifest_file = File.open( manifest_path )
abort("rake aborted: repo must contain valid manifest.yml") unless File.exist? manifest_file
manifest = YAML.load( manifest_file )
manifest_file.close
manifest
end

def ask(message, valid_options)
if valid_options
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
else
answer = get_stdin(message)
end
answer
end

def get_stdin(message)
print message
STDIN.gets.chomp
end

#Load custom rake scripts
Dir['_rake/*.rake'].each { |r| load r }
Loading