hashup 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +45 -0
  6. data/Rakefile +5 -0
  7. data/bin/hashup +4 -0
  8. data/hashup.gemspec +28 -0
  9. data/lib/hashup.rb +14 -0
  10. data/lib/hashup/configuration.rb +26 -0
  11. data/lib/hashup/generator.rb +103 -0
  12. data/lib/hashup/post.rb +22 -0
  13. data/lib/hashup/site.rb +74 -0
  14. data/lib/hashup/templates/config.yml +8 -0
  15. data/lib/hashup/templates/contents/_pages/about.ma +7 -0
  16. data/lib/hashup/templates/contents/_posts/markascend.ma +54 -0
  17. data/lib/hashup/templates/contents/data.yml +9 -0
  18. data/lib/hashup/templates/themes/_layout/_footer.slim +11 -0
  19. data/lib/hashup/templates/themes/_layout/_header.slim +12 -0
  20. data/lib/hashup/templates/themes/_layout/_layout.slim +5 -0
  21. data/lib/hashup/templates/themes/_layout/_nav.slim +7 -0
  22. data/lib/hashup/templates/themes/assets/flat-ui/_config.sass +16 -0
  23. data/lib/hashup/templates/themes/assets/flat-ui/_icon-font-24.sass +91 -0
  24. data/lib/hashup/templates/themes/assets/flat-ui/_icon-font.sass +91 -0
  25. data/lib/hashup/templates/themes/assets/flat-ui/_mixins.sass +96 -0
  26. data/lib/hashup/templates/themes/assets/flat-ui/_spaces.sass +129 -0
  27. data/lib/hashup/templates/themes/assets/flat-ui/flat-ui.sass +39 -0
  28. data/lib/hashup/templates/themes/assets/flat-ui/modules/_btn.sass +73 -0
  29. data/lib/hashup/templates/themes/assets/flat-ui/modules/_checkbox-and-radio.sass +86 -0
  30. data/lib/hashup/templates/themes/assets/flat-ui/modules/_demo.sass +228 -0
  31. data/lib/hashup/templates/themes/assets/flat-ui/modules/_footer.sass +57 -0
  32. data/lib/hashup/templates/themes/assets/flat-ui/modules/_input.sass +66 -0
  33. data/lib/hashup/templates/themes/assets/flat-ui/modules/_login.sass +95 -0
  34. data/lib/hashup/templates/themes/assets/flat-ui/modules/_navbar.sass +152 -0
  35. data/lib/hashup/templates/themes/assets/flat-ui/modules/_pager.sass +56 -0
  36. data/lib/hashup/templates/themes/assets/flat-ui/modules/_pagination.sass +75 -0
  37. data/lib/hashup/templates/themes/assets/flat-ui/modules/_palette.sass +88 -0
  38. data/lib/hashup/templates/themes/assets/flat-ui/modules/_progress.sass +29 -0
  39. data/lib/hashup/templates/themes/assets/flat-ui/modules/_select.sass +163 -0
  40. data/lib/hashup/templates/themes/assets/flat-ui/modules/_share.sass +34 -0
  41. data/lib/hashup/templates/themes/assets/flat-ui/modules/_tagsinput.sass +91 -0
  42. data/lib/hashup/templates/themes/assets/flat-ui/modules/_tile.sass +42 -0
  43. data/lib/hashup/templates/themes/assets/flat-ui/modules/_todo.sass +77 -0
  44. data/lib/hashup/templates/themes/assets/flat-ui/modules/_toggle.sass +85 -0
  45. data/lib/hashup/templates/themes/assets/flat-ui/modules/_tooltip.sass +45 -0
  46. data/lib/hashup/templates/themes/assets/flat-ui/modules/_type.sass +43 -0
  47. data/lib/hashup/templates/themes/assets/flat-ui/modules/_ui-slider.sass +44 -0
  48. data/lib/hashup/templates/themes/assets/flat-ui/modules/_video.sass +358 -0
  49. data/lib/hashup/templates/themes/index.slim +9 -0
  50. data/lib/hashup/templates/themes/post.slim +3 -0
  51. data/lib/hashup/templates/themes/static/css/bootstrap.css +6039 -0
  52. data/lib/hashup/templates/themes/static/css/custom.css +11 -0
  53. data/lib/hashup/templates/themes/static/css/flat-ui.css +2533 -0
  54. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.dev.svg +112 -0
  55. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.eot +0 -0
  56. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.svg +112 -0
  57. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.ttf +0 -0
  58. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-16.woff +0 -0
  59. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.dev.svg +111 -0
  60. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.eot +0 -0
  61. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.svg +111 -0
  62. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.ttf +0 -0
  63. data/lib/hashup/templates/themes/static/fonts/Flat-UI-Icons-24.woff +0 -0
  64. data/lib/hashup/templates/themes/static/images/checkbox-2x.png +0 -0
  65. data/lib/hashup/templates/themes/static/images/checkbox.png +0 -0
  66. data/lib/hashup/templates/themes/static/images/demo/browser-2x.png +0 -0
  67. data/lib/hashup/templates/themes/static/images/demo/browser-author.jpg +0 -0
  68. data/lib/hashup/templates/themes/static/images/demo/browser-pic-1.jpg +0 -0
  69. data/lib/hashup/templates/themes/static/images/demo/browser-pic-2.jpg +0 -0
  70. data/lib/hashup/templates/themes/static/images/demo/browser-pic-3.jpg +0 -0
  71. data/lib/hashup/templates/themes/static/images/demo/browser-pic-4.jpg +0 -0
  72. data/lib/hashup/templates/themes/static/images/demo/browser-pic-5.jpg +0 -0
  73. data/lib/hashup/templates/themes/static/images/demo/browser-pic-6.jpg +0 -0
  74. data/lib/hashup/templates/themes/static/images/demo/browser.png +0 -0
  75. data/lib/hashup/templates/themes/static/images/demo/html-icon.png +0 -0
  76. data/lib/hashup/templates/themes/static/images/demo/logo-mask-2x.png +0 -0
  77. data/lib/hashup/templates/themes/static/images/demo/logo-mask.png +0 -0
  78. data/lib/hashup/templates/themes/static/images/demo/video.jpg +0 -0
  79. data/lib/hashup/templates/themes/static/images/favicon.ico +0 -0
  80. data/lib/hashup/templates/themes/static/images/footer/logo.png +0 -0
  81. data/lib/hashup/templates/themes/static/images/illustrations/bag.png +0 -0
  82. data/lib/hashup/templates/themes/static/images/illustrations/book.png +0 -0
  83. data/lib/hashup/templates/themes/static/images/illustrations/calendar.png +0 -0
  84. data/lib/hashup/templates/themes/static/images/illustrations/clipboard.png +0 -0
  85. data/lib/hashup/templates/themes/static/images/illustrations/colors.png +0 -0
  86. data/lib/hashup/templates/themes/static/images/illustrations/compass.png +0 -0
  87. data/lib/hashup/templates/themes/static/images/illustrations/gift.png +0 -0
  88. data/lib/hashup/templates/themes/static/images/illustrations/infinity.png +0 -0
  89. data/lib/hashup/templates/themes/static/images/illustrations/mail.png +0 -0
  90. data/lib/hashup/templates/themes/static/images/illustrations/map.png +0 -0
  91. data/lib/hashup/templates/themes/static/images/illustrations/paper.png +0 -0
  92. data/lib/hashup/templates/themes/static/images/illustrations/retina.png +0 -0
  93. data/lib/hashup/templates/themes/static/images/illustrations/share.png +0 -0
  94. data/lib/hashup/templates/themes/static/images/illustrations/time.png +0 -0
  95. data/lib/hashup/templates/themes/static/images/login/icon.png +0 -0
  96. data/lib/hashup/templates/themes/static/images/login/imac-2x.png +0 -0
  97. data/lib/hashup/templates/themes/static/images/login/imac.png +0 -0
  98. data/lib/hashup/templates/themes/static/images/pager/next.png +0 -0
  99. data/lib/hashup/templates/themes/static/images/pager/previous.png +0 -0
  100. data/lib/hashup/templates/themes/static/images/radio-2x.png +0 -0
  101. data/lib/hashup/templates/themes/static/images/radio.png +0 -0
  102. data/lib/hashup/templates/themes/static/images/select/toggle.png +0 -0
  103. data/lib/hashup/templates/themes/static/images/tile/ribbon-2x.png +0 -0
  104. data/lib/hashup/templates/themes/static/images/tile/ribbon.png +0 -0
  105. data/lib/hashup/templates/themes/static/images/todo/done-2x.png +0 -0
  106. data/lib/hashup/templates/themes/static/images/todo/done.png +0 -0
  107. data/lib/hashup/templates/themes/static/images/todo/search-2x.png +0 -0
  108. data/lib/hashup/templates/themes/static/images/todo/search.png +0 -0
  109. data/lib/hashup/templates/themes/static/images/todo/todo-2x.png +0 -0
  110. data/lib/hashup/templates/themes/static/images/todo/todo.png +0 -0
  111. data/lib/hashup/templates/themes/static/images/toggle/block-off.png +0 -0
  112. data/lib/hashup/templates/themes/static/images/toggle/block-on.png +0 -0
  113. data/lib/hashup/templates/themes/static/images/toggle/icon-off-2x.png +0 -0
  114. data/lib/hashup/templates/themes/static/images/toggle/icon-off.png +0 -0
  115. data/lib/hashup/templates/themes/static/images/toggle/icon-on-2x.png +0 -0
  116. data/lib/hashup/templates/themes/static/images/toggle/icon-on.png +0 -0
  117. data/lib/hashup/templates/themes/static/images/video/fullscreen-2x.png +0 -0
  118. data/lib/hashup/templates/themes/static/images/video/fullscreen.png +0 -0
  119. data/lib/hashup/templates/themes/static/images/video/pause-2x.png +0 -0
  120. data/lib/hashup/templates/themes/static/images/video/pause.png +0 -0
  121. data/lib/hashup/templates/themes/static/images/video/play-2x.png +0 -0
  122. data/lib/hashup/templates/themes/static/images/video/play.png +0 -0
  123. data/lib/hashup/templates/themes/static/images/video/poster.jpg +0 -0
  124. data/lib/hashup/templates/themes/static/images/video/volume-full-2x.png +0 -0
  125. data/lib/hashup/templates/themes/static/images/video/volume-full.png +0 -0
  126. data/lib/hashup/templates/themes/static/images/video/volume-off-2x.png +0 -0
  127. data/lib/hashup/templates/themes/static/images/video/volume-off.png +0 -0
  128. data/lib/hashup/templates/themes/static/js/application.js +51 -0
  129. data/lib/hashup/templates/themes/static/js/bootstrap-tooltip.js +353 -0
  130. data/lib/hashup/templates/themes/static/js/custom_checkbox_and_radio.js +53 -0
  131. data/lib/hashup/templates/themes/static/js/custom_radio.js +28 -0
  132. data/lib/hashup/templates/themes/static/js/html5shiv.js +8 -0
  133. data/lib/hashup/templates/themes/static/js/icon-font-ie7.js +44 -0
  134. data/lib/hashup/templates/themes/static/js/jquery-1.8.2.min.js +2 -0
  135. data/lib/hashup/templates/themes/static/js/jquery-ui-1.10.0.custom.min.js +6 -0
  136. data/lib/hashup/templates/themes/static/js/jquery.dropkick-1.0.0.js +400 -0
  137. data/lib/hashup/templates/themes/static/js/jquery.placeholder.js +157 -0
  138. data/lib/hashup/templates/themes/static/js/jquery.tagsinput.js +354 -0
  139. data/lib/hashup/templates/themes/static/js/lte-ie7-24.js +44 -0
  140. data/lib/hashup/templates/themes/static/pygments-css/README.rst +27 -0
  141. data/lib/hashup/templates/themes/static/pygments-css/autumn.css +58 -0
  142. data/lib/hashup/templates/themes/static/pygments-css/borland.css +46 -0
  143. data/lib/hashup/templates/themes/static/pygments-css/bw.css +34 -0
  144. data/lib/hashup/templates/themes/static/pygments-css/colorful.css +61 -0
  145. data/lib/hashup/templates/themes/static/pygments-css/default.css +62 -0
  146. data/lib/hashup/templates/themes/static/pygments-css/emacs.css +61 -0
  147. data/lib/hashup/templates/themes/static/pygments-css/friendly.css +61 -0
  148. data/lib/hashup/templates/themes/static/pygments-css/fruity.css +69 -0
  149. data/lib/hashup/templates/themes/static/pygments-css/github.css +61 -0
  150. data/lib/hashup/templates/themes/static/pygments-css/manni.css +61 -0
  151. data/lib/hashup/templates/themes/static/pygments-css/monokai.css +59 -0
  152. data/lib/hashup/templates/themes/static/pygments-css/murphy.css +61 -0
  153. data/lib/hashup/templates/themes/static/pygments-css/native.css +69 -0
  154. data/lib/hashup/templates/themes/static/pygments-css/pastie.css +60 -0
  155. data/lib/hashup/templates/themes/static/pygments-css/perldoc.css +58 -0
  156. data/lib/hashup/templates/themes/static/pygments-css/tango.css +69 -0
  157. data/lib/hashup/templates/themes/static/pygments-css/trac.css +59 -0
  158. data/lib/hashup/templates/themes/static/pygments-css/vim.css +69 -0
  159. data/lib/hashup/templates/themes/static/pygments-css/vs.css +33 -0
  160. data/lib/hashup/templates/themes/static/pygments-css/zenburn.css +1 -0
  161. data/lib/hashup/templates/themes/stylesheets/style.css +0 -0
  162. data/lib/hashup/version.rb +3 -0
  163. data/spec/generator_spec.rb +11 -0
  164. data/spec/hashup_spec.rb +12 -0
  165. data/spec/spec_helper.rb +9 -0
  166. metadata +310 -0
@@ -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
@@ -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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hashup.gemspec
4
+ gem "rspec"
@@ -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.
@@ -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
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + "/../lib/hashup"
4
+ Hashup::Generator.start()
@@ -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
@@ -0,0 +1,14 @@
1
+ require "hashup/version"
2
+ require 'hashup/generator'
3
+ require "hashup/site"
4
+ require "hashup/post"
5
+ require "hashup/configuration"
6
+ require "slim"
7
+ require "thor"
8
+ require "markascend"
9
+
10
+ module Hashup
11
+ # Your code goes here...
12
+ end
13
+
14
+
@@ -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
@@ -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
@@ -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,8 @@
1
+ ---
2
+ template_dir: "themes"
3
+ content_dir: "contents"
4
+ posts_folder: "_posts"
5
+ pages_folder: "_pages"
6
+ output_dir: "output"
7
+ server:
8
+ port: 10086
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: about
3
+ date: 2013-05-01 15:25:10 +0800
4
+ description: this is about me
5
+ ---
6
+
7
+ hello I'm Krazy
@@ -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]