hashup 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +5 -0
- data/bin/hashup +4 -0
- data/hashup.gemspec +28 -0
- data/lib/hashup.rb +14 -0
- data/lib/hashup/configuration.rb +26 -0
- data/lib/hashup/generator.rb +103 -0
- data/lib/hashup/post.rb +22 -0
- data/lib/hashup/site.rb +74 -0
- data/lib/hashup/templates/config.yml +8 -0
- data/lib/hashup/templates/contents/_pages/about.ma +7 -0
- data/lib/hashup/templates/contents/_posts/markascend.ma +54 -0
- data/lib/hashup/templates/contents/data.yml +9 -0
- data/lib/hashup/templates/themes/_layout/_footer.slim +11 -0
- data/lib/hashup/templates/themes/_layout/_header.slim +12 -0
- data/lib/hashup/templates/themes/_layout/_layout.slim +5 -0
- data/lib/hashup/templates/themes/_layout/_nav.slim +7 -0
- data/lib/hashup/templates/themes/assets/flat-ui/_config.sass +16 -0
- data/lib/hashup/templates/themes/assets/flat-ui/_icon-font-24.sass +91 -0
- data/lib/hashup/templates/themes/assets/flat-ui/_icon-font.sass +91 -0
- data/lib/hashup/templates/themes/assets/flat-ui/_mixins.sass +96 -0
- data/lib/hashup/templates/themes/assets/flat-ui/_spaces.sass +129 -0
- data/lib/hashup/templates/themes/assets/flat-ui/flat-ui.sass +39 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_btn.sass +73 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_checkbox-and-radio.sass +86 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_demo.sass +228 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_footer.sass +57 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_input.sass +66 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_login.sass +95 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_navbar.sass +152 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_pager.sass +56 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_pagination.sass +75 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_palette.sass +88 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_progress.sass +29 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_select.sass +163 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_share.sass +34 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_tagsinput.sass +91 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_tile.sass +42 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_todo.sass +77 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_toggle.sass +85 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_tooltip.sass +45 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_type.sass +43 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_ui-slider.sass +44 -0
- data/lib/hashup/templates/themes/assets/flat-ui/modules/_video.sass +358 -0
- data/lib/hashup/templates/themes/index.slim +9 -0
- data/lib/hashup/templates/themes/post.slim +3 -0
- data/lib/hashup/templates/themes/static/css/bootstrap.css +6039 -0
- data/lib/hashup/templates/themes/static/css/custom.css +11 -0
- data/lib/hashup/templates/themes/static/css/flat-ui.css +2533 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.dev.svg +112 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.eot +0 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.svg +112 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.ttf +0 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.woff +0 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.dev.svg +111 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.eot +0 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.svg +111 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.ttf +0 -0
- data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.woff +0 -0
- data/lib/hashup/templates/themes/static/images/checkbox-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/checkbox.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-author.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-1.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-2.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-3.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-4.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-5.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser-pic-6.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/demo/browser.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/html-icon.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/logo-mask-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/logo-mask.png +0 -0
- data/lib/hashup/templates/themes/static/images/demo/video.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/favicon.ico +0 -0
- data/lib/hashup/templates/themes/static/images/footer/logo.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/bag.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/book.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/calendar.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/clipboard.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/colors.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/compass.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/gift.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/infinity.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/mail.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/map.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/paper.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/retina.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/share.png +0 -0
- data/lib/hashup/templates/themes/static/images/illustrations/time.png +0 -0
- data/lib/hashup/templates/themes/static/images/login/icon.png +0 -0
- data/lib/hashup/templates/themes/static/images/login/imac-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/login/imac.png +0 -0
- data/lib/hashup/templates/themes/static/images/pager/next.png +0 -0
- data/lib/hashup/templates/themes/static/images/pager/previous.png +0 -0
- data/lib/hashup/templates/themes/static/images/radio-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/radio.png +0 -0
- data/lib/hashup/templates/themes/static/images/select/toggle.png +0 -0
- data/lib/hashup/templates/themes/static/images/tile/ribbon-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/tile/ribbon.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/done-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/done.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/search-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/search.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/todo-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/todo/todo.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/block-off.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/block-on.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/icon-off-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/icon-off.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/icon-on-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/toggle/icon-on.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/fullscreen-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/fullscreen.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/pause-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/pause.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/play-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/play.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/poster.jpg +0 -0
- data/lib/hashup/templates/themes/static/images/video/volume-full-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/volume-full.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/volume-off-2x.png +0 -0
- data/lib/hashup/templates/themes/static/images/video/volume-off.png +0 -0
- data/lib/hashup/templates/themes/static/js/application.js +51 -0
- data/lib/hashup/templates/themes/static/js/bootstrap-tooltip.js +353 -0
- data/lib/hashup/templates/themes/static/js/custom_checkbox_and_radio.js +53 -0
- data/lib/hashup/templates/themes/static/js/custom_radio.js +28 -0
- data/lib/hashup/templates/themes/static/js/html5shiv.js +8 -0
- data/lib/hashup/templates/themes/static/js/icon-font-ie7.js +44 -0
- data/lib/hashup/templates/themes/static/js/jquery-1.8.2.min.js +2 -0
- data/lib/hashup/templates/themes/static/js/jquery-ui-1.10.0.custom.min.js +6 -0
- data/lib/hashup/templates/themes/static/js/jquery.dropkick-1.0.0.js +400 -0
- data/lib/hashup/templates/themes/static/js/jquery.placeholder.js +157 -0
- data/lib/hashup/templates/themes/static/js/jquery.tagsinput.js +354 -0
- data/lib/hashup/templates/themes/static/js/lte-ie7-24.js +44 -0
- data/lib/hashup/templates/themes/static/pygments-css/README.rst +27 -0
- data/lib/hashup/templates/themes/static/pygments-css/autumn.css +58 -0
- data/lib/hashup/templates/themes/static/pygments-css/borland.css +46 -0
- data/lib/hashup/templates/themes/static/pygments-css/bw.css +34 -0
- data/lib/hashup/templates/themes/static/pygments-css/colorful.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/default.css +62 -0
- data/lib/hashup/templates/themes/static/pygments-css/emacs.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/friendly.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/fruity.css +69 -0
- data/lib/hashup/templates/themes/static/pygments-css/github.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/manni.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/monokai.css +59 -0
- data/lib/hashup/templates/themes/static/pygments-css/murphy.css +61 -0
- data/lib/hashup/templates/themes/static/pygments-css/native.css +69 -0
- data/lib/hashup/templates/themes/static/pygments-css/pastie.css +60 -0
- data/lib/hashup/templates/themes/static/pygments-css/perldoc.css +58 -0
- data/lib/hashup/templates/themes/static/pygments-css/tango.css +69 -0
- data/lib/hashup/templates/themes/static/pygments-css/trac.css +59 -0
- data/lib/hashup/templates/themes/static/pygments-css/vim.css +69 -0
- data/lib/hashup/templates/themes/static/pygments-css/vs.css +33 -0
- data/lib/hashup/templates/themes/static/pygments-css/zenburn.css +1 -0
- data/lib/hashup/templates/themes/stylesheets/style.css +0 -0
- data/lib/hashup/version.rb +3 -0
- data/spec/generator_spec.rb +11 -0
- data/spec/hashup_spec.rb +12 -0
- data/spec/spec_helper.rb +9 -0
- metadata +310 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b95ef7ceb921e1aca6cc03fc69100ea1169e346b
|
4
|
+
data.tar.gz: c6695bc516e4e6e312562c156491dc53d4a6c1db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56d94f7af750403efac11d4d6d28d6c12a7b864fbd7f03b8efe530178ee9a651c792e0d9ad8b93644953a858e39591c8d556b8aa68438756dae615d53322f3cc
|
7
|
+
data.tar.gz: c647273b41999ddc4d30b8ddbf57a72f4df9f62c121f0e568941eef76185c5965fdfc626897b327a578ad6f6c485fc17cf711983d161d81a07d01549973d25bc
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*swp
|
19
|
+
*swo
|
20
|
+
lib/hashup/templates/output/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 krazy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Hashup
|
2
|
+
**Yet another static sites generator**
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem ins hashup
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ hashup setup github_id.github.com
|
13
|
+
|
14
|
+
And then:
|
15
|
+
|
16
|
+
$ cd myblog
|
17
|
+
$ hashup preview
|
18
|
+
|
19
|
+
And then deploy to github:
|
20
|
+
|
21
|
+
$ hashup deploy
|
22
|
+
|
23
|
+
There you go!
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Post a blog
|
28
|
+
|
29
|
+
hashup post
|
30
|
+
|
31
|
+
Create a page
|
32
|
+
|
33
|
+
hashup page
|
34
|
+
|
35
|
+
## Features
|
36
|
+
|
37
|
+
...
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/hashup
ADDED
data/hashup.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hashup/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hashup"
|
8
|
+
spec.version = Hashup::VERSION
|
9
|
+
spec.authors = ["krazy"]
|
10
|
+
spec.email = ["lixiangstar@gmail.com"]
|
11
|
+
spec.description = %q{yet another static sites generator}
|
12
|
+
spec.summary = %q{a generator}
|
13
|
+
spec.homepage = "http://github.io/krazylee"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = 'hashup'
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "thor"
|
24
|
+
spec.add_development_dependency "markascend"
|
25
|
+
spec.add_development_dependency "pygments"
|
26
|
+
spec.add_development_dependency "tilt"
|
27
|
+
spec.add_development_dependency "slim"
|
28
|
+
end
|
data/lib/hashup.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "yaml"
|
2
|
+
module Hashup
|
3
|
+
class Configuration
|
4
|
+
DEFAULTS = {
|
5
|
+
'template_dir' => "themes",
|
6
|
+
'content_dir' => "contents",
|
7
|
+
'output_dir' => "output",
|
8
|
+
'server' => {
|
9
|
+
'port' => 9817
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize filename
|
14
|
+
if File.exists? filename
|
15
|
+
@filename = filename
|
16
|
+
else
|
17
|
+
puts "#{filename} not found, maybe you are not in the right folder"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def configs
|
22
|
+
return YAML.load_file @filename if @filename
|
23
|
+
DEFAULTS
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "thor"
|
3
|
+
module Hashup
|
4
|
+
class Generator < ::Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.dirname(__FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "setup", "create your first site"
|
12
|
+
def setup(mysite)
|
13
|
+
return if root?
|
14
|
+
puts "setup #{mysite}..."
|
15
|
+
directory("#{File.dirname(__FILE__)}/templates/", mysite, :exclude_pattern => /themes|contents/)
|
16
|
+
%w[contents themes].each do |item|
|
17
|
+
empty_directory(item)
|
18
|
+
directory("#{File.dirname(__FILE__)}/templates/#{item}", "#{mysite}/#{item}", :verbose => false)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "compile FILE", "compile a markdown file"
|
23
|
+
def compile(file)
|
24
|
+
fragment = Markascend.compile (File.open(file, "r").read)
|
25
|
+
File.open("#{File.basename(file, ".ma")}.html", "w+") do |f|
|
26
|
+
f.write(fragment)
|
27
|
+
end
|
28
|
+
puts "#{file} compiled"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "preview", "compile all files"
|
32
|
+
def preview
|
33
|
+
if root?
|
34
|
+
empty_directory("output")
|
35
|
+
site = Hashup::Site.new
|
36
|
+
site.generate
|
37
|
+
@configs = site.configs
|
38
|
+
directory("#{File.dirname(__FILE__)}/templates/#{@configs["template_dir"]}/static", "#{@configs["output_dir"]}/static", :verbose => false)
|
39
|
+
run_server
|
40
|
+
else
|
41
|
+
puts "not in the root"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "post", "create a post"
|
46
|
+
def post
|
47
|
+
title = ask("the title of this post: ")
|
48
|
+
tags = ask("tags(seperated by comma or space): ").strip().split(/\s|,/).to_s.gsub(/"/,"")
|
49
|
+
site = Hashup::Site.new
|
50
|
+
@configs = site.configs
|
51
|
+
create_file(File.join("#{@configs["content_dir"]}", "#{@configs["output_dir"]}", "#{title.gsub(/\s/, "_")}.ma")) do
|
52
|
+
<<META
|
53
|
+
---
|
54
|
+
title: #{title}
|
55
|
+
tags: #{tags}
|
56
|
+
date: #{Time.new.to_s}
|
57
|
+
---
|
58
|
+
META
|
59
|
+
end if title
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "page", "create a page"
|
63
|
+
def page
|
64
|
+
name = ask("the name of the page: ")
|
65
|
+
description = ask("description: ").chomp!
|
66
|
+
create_file(File.join("#{@configs["content_dir"]}", "#{@configs["pages_folder"]}", "#{name}.ma")) do
|
67
|
+
<<META
|
68
|
+
---
|
69
|
+
title: #{name}
|
70
|
+
date: #{Time.new.to_s}
|
71
|
+
description: #{description}
|
72
|
+
---
|
73
|
+
META
|
74
|
+
end if name
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "deploy", "deploy to github"
|
78
|
+
def deploy
|
79
|
+
site = Hashup::Site.new
|
80
|
+
@configs = site.configs
|
81
|
+
Dir.chdir "#{@configs["output_dir"]}" do
|
82
|
+
system "git add . -f"
|
83
|
+
puts "commiting site, updated at #{Time.now.utc}"
|
84
|
+
message = "Site updated at #{Time.now.utc}"
|
85
|
+
system "git commit -m \"#{message}\""
|
86
|
+
system "git push origin master --force"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "draft", "create a draft"
|
91
|
+
def draft(doc)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def root?
|
96
|
+
File.exists? "config.yml"
|
97
|
+
end
|
98
|
+
|
99
|
+
def run_server
|
100
|
+
`white_castle ./output`
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/hashup/post.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "markascend"
|
3
|
+
module Hashup
|
4
|
+
class Post
|
5
|
+
attr_accessor :filename, :title, :date, :tags, :metadata, :contents
|
6
|
+
def initialize post
|
7
|
+
self.parse_post post
|
8
|
+
@filename = "#{File.basename(post,".ma")}.html"
|
9
|
+
@title = @metadata["title"]
|
10
|
+
@date = @metadata["date"]
|
11
|
+
@tags = @metadata["tags"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_post post
|
15
|
+
contents= File.open(post).read
|
16
|
+
if(md = contents.match(/^(?<metadata>---\s*\n.*?\n?)^(---\s*$\n?)/m))
|
17
|
+
@contents = ::Markascend.compile md.post_match, toc: true
|
18
|
+
@metadata = YAML.load(md[:metadata])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/hashup/site.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "slim"
|
2
|
+
require "yaml"
|
3
|
+
require "ostruct"
|
4
|
+
require "markascend"
|
5
|
+
require_relative "configuration"
|
6
|
+
|
7
|
+
module Hashup
|
8
|
+
class Site
|
9
|
+
attr_reader :configs, :infos
|
10
|
+
def initialize
|
11
|
+
Slim::Engine.set_default_options pretty: true, sort_attrs: false
|
12
|
+
@configs = self.load_config "config.yml"
|
13
|
+
@infos = self.load_infos
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate
|
17
|
+
# generate posts
|
18
|
+
get_posts.each do |post|
|
19
|
+
article = Hashup::Post.new post
|
20
|
+
@infos["post"] = OpenStruct.new(article.metadata)
|
21
|
+
generated_post = Tilt.new("themes/_layout/_layout.slim").render(OpenStruct.new(@infos)) {
|
22
|
+
@infos["article"] = article.contents
|
23
|
+
Slim::Template.new("themes/post.slim").render(OpenStruct.new(@infos))
|
24
|
+
}
|
25
|
+
puts "#{post} generated.."
|
26
|
+
File.open("#{@configs["output_dir"]}/#{File.basename(post, ".ma")}.html", 'w+') do |f|
|
27
|
+
f.puts generated_post
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# generate index.html
|
32
|
+
File.open("#{@configs["output_dir"]}/index.html", 'w+') do |f|
|
33
|
+
index = Tilt.new("themes/_layout/_layout.slim").render(OpenStruct.new(@infos)) {
|
34
|
+
@infos["list"] = self.get_generated_posts_list
|
35
|
+
Slim::Template.new("themes/index.slim").render(OpenStruct.new(@infos))
|
36
|
+
}
|
37
|
+
f.puts index
|
38
|
+
puts "index.html generated"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_posts
|
43
|
+
Dir.glob "#{@configs["content_dir"]}/#{@configs["posts_folder"]}/**/*.{ma, mad, md, markdown}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_generated_posts_list
|
47
|
+
posts_list = []
|
48
|
+
get_posts.each do |post|
|
49
|
+
posts_list << (Hashup::Post.new post)
|
50
|
+
end
|
51
|
+
posts_list
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_infos
|
55
|
+
infos = {}
|
56
|
+
Dir.glob("**/*.{yml, yaml}").map do |info|
|
57
|
+
next unless info =~ Regexp.new(@configs["content_dir"])
|
58
|
+
infos.merge! (YAML.load_file info)
|
59
|
+
end
|
60
|
+
infos
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_config config_file
|
64
|
+
configrable = Hashup::Configuration.new config_file
|
65
|
+
configrable.configs
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def render_file(filename)
|
71
|
+
ss = Hashup::Site.new
|
72
|
+
infos = OpenStruct.new(ss.load_infos)
|
73
|
+
Slim::Template.new("themes/_layout/#{filename}").render(infos)
|
74
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
title: "Markascend语法简介"
|
3
|
+
date: 2012-02-04
|
4
|
+
---
|
5
|
+
|
6
|
+
\hi(ruby)
|
7
|
+
h1#compile Compile
|
8
|
+
|
|
9
|
+
Markascend.compile src, options
|
10
|
+
|
11
|
+
h3#api compile api
|
12
|
+
this is the api
|
13
|
+
|
14
|
+
h1#options Options
|
15
|
+
|
16
|
+
- `:path`, source file path. Used for static files lookup. If not given, use the current working directory.
|
17
|
+
- `:autolink`, default value is `%w[http https ftp mailto]`
|
18
|
+
- `:inline_img`, compile image into inlined base64, default = `false`
|
19
|
+
- `:macros`, specify the names of enabled macros. Other macros will be treated as plain text. The default value is `Markascend::DEFAULT_MACROS`.
|
20
|
+
- `:line_units`, specify the inline parsers to be used (be careful with the order!). The default value is `Markascend::DEFAULT_LINE_UNITS`.
|
21
|
+
- `:sandbox`, a hybrid option to tweak the syntax to be generally safe for user inputs. `false` by default. When set to `true`, footnotes are disabled, header anchors are ignored, and enabled macros are set to `Markascend::SANDBOX_MACROS`. The sandbox macro list can be overriden by the `:macros` option.
|
22
|
+
- `:toc`, whether generate table of contents. `false` by default. Header anchors can be customized or generated in the form of `"-#{N}"`. Note that there's no "permalink" generator for headers, but you can implement one with simple javascript.
|
23
|
+
|
24
|
+
h1#macros Customizing macros
|
25
|
+
|
26
|
+
More macro processors can be added by
|
27
|
+
|
28
|
+
|
|
29
|
+
class Markascend::Macro
|
30
|
+
def parse_fancy_macro
|
31
|
+
... compose result string with: env, content, inline
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Macro names are limited to names like ruby methods.
|
36
|
+
|
37
|
+
|
|
38
|
+
Markascend.compile src, macros: %w[fancy_macro del]
|
39
|
+
|
40
|
+
h1#line-unit Customizing line-unit parsers
|
41
|
+
|
42
|
+
More line-unit parsers can be added by
|
43
|
+
|
44
|
+
|
|
45
|
+
class Markascend::LineUnit
|
46
|
+
def parse_at
|
47
|
+
... compose result string with: env, line, block, linenum
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
The list of inline parsers can be changed, or reordered
|
52
|
+
|
53
|
+
|
|
54
|
+
Markascend.compile src, line_units: Markascend::DEFAULT_LINE_UNITS + %w[at]
|