write_down 0.0.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -21
  3. data/.travis.yml +4 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE.txt +17 -18
  6. data/README.md +20 -8
  7. data/Rakefile +9 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/exe/write_down +3 -0
  11. data/lib/write_down/converter/base.rb +18 -0
  12. data/lib/write_down/converter/markdown.rb +18 -0
  13. data/lib/write_down/converter/org.rb +18 -0
  14. data/lib/write_down/erb/container.erb +19 -0
  15. data/lib/write_down/erb/essay.erb +5 -0
  16. data/lib/write_down/erb/layout.erb +64 -0
  17. data/lib/write_down/erb/page.erb +4 -0
  18. data/lib/write_down/erb/post.erb +5 -0
  19. data/lib/write_down/erb/slide.erb +79 -0
  20. data/lib/write_down/model/asset.rb +36 -0
  21. data/lib/write_down/model/base.rb +63 -0
  22. data/lib/write_down/model/container.rb +35 -0
  23. data/lib/write_down/model/essay.rb +35 -0
  24. data/lib/write_down/model/layout.rb +75 -0
  25. data/lib/write_down/model/page.rb +47 -0
  26. data/lib/write_down/model/post.rb +47 -0
  27. data/lib/write_down/model/slide.rb +27 -0
  28. data/lib/write_down/utils/qiniu_sync.rb +23 -0
  29. data/lib/write_down/version.rb +1 -1
  30. data/lib/write_down.rb +13 -33
  31. data/write_down.gemspec +23 -12
  32. metadata +54 -91
  33. data/bin/write_down +0 -43
  34. data/lib/write_down/article.rb +0 -64
  35. data/lib/write_down/configuration.rb +0 -6
  36. data/lib/write_down/converter.rb +0 -8
  37. data/lib/write_down/page.rb +0 -6
  38. data/lib/write_down/series.rb +0 -10
  39. data/lib/write_down/site.rb +0 -10
  40. data/lib/write_down/template.rb +0 -20
  41. data/template/emacs/404.html +0 -157
  42. data/template/emacs/CHANGELOG.md +0 -133
  43. data/template/emacs/CONTRIBUTING.md +0 -154
  44. data/template/emacs/LICENSE.md +0 -19
  45. data/template/emacs/README.md +0 -1
  46. data/template/emacs/apple-touch-icon-precomposed.png +0 -0
  47. data/template/emacs/crossdomain.xml +0 -15
  48. data/template/emacs/css/custom.css +0 -18
  49. data/template/emacs/css/main.css +0 -304
  50. data/template/emacs/css/normalize.css +0 -527
  51. data/template/emacs/favicon.ico +0 -0
  52. data/template/emacs/humans.txt +0 -15
  53. data/template/emacs/img/.gitignore +0 -0
  54. data/template/emacs/index.html +0 -62
  55. data/template/emacs/js/main.js +0 -1
  56. data/template/emacs/js/plugins.js +0 -24
  57. data/template/emacs/js/vendor/jquery-1.10.2.min.js +0 -6
  58. data/template/emacs/js/vendor/modernizr-2.6.2.min.js +0 -4
  59. data/template/emacs/post.html +0 -80
  60. data/template/emacs/robots.txt +0 -3
  61. data/template/simple/404.html +0 -157
  62. data/template/simple/CNAME +0 -1
  63. data/template/simple/README.md +0 -1
  64. data/template/simple/_disqus.mustache +0 -19
  65. data/template/simple/_footer.mustache +0 -28
  66. data/template/simple/_header.mustache +0 -38
  67. data/template/simple/apple-touch-icon-precomposed.png +0 -0
  68. data/template/simple/crossdomain.xml +0 -15
  69. data/template/simple/css/layout.css +0 -72
  70. data/template/simple/css/main.css +0 -304
  71. data/template/simple/css/normalize.css +0 -527
  72. data/template/simple/favicon.ico +0 -0
  73. data/template/simple/humans.txt +0 -15
  74. data/template/simple/img/.gitignore +0 -0
  75. data/template/simple/index.html +0 -12
  76. data/template/simple/js/main.js +0 -1
  77. data/template/simple/js/plugins.js +0 -24
  78. data/template/simple/js/vendor/jquery-1.10.2.min.js +0 -6
  79. data/template/simple/js/vendor/modernizr-2.6.2.min.js +0 -4
  80. data/template/simple/post.html +0 -9
  81. data/template/simple/robots.txt +0 -3
  82. data/theme/ghost/assets/css/screen.css +0 -911
  83. data/theme/ghost/index.html +0 -75
  84. data/theme/ghost/post.html +0 -112
  85. data/theme/html5-boilerplate/.gitattributes +0 -1
  86. data/theme/html5-boilerplate/.gitignore +0 -2
  87. data/theme/html5-boilerplate/.htaccess +0 -551
  88. data/theme/html5-boilerplate/404.html +0 -157
  89. data/theme/html5-boilerplate/CHANGELOG.md +0 -133
  90. data/theme/html5-boilerplate/CONTRIBUTING.md +0 -154
  91. data/theme/html5-boilerplate/LICENSE.md +0 -19
  92. data/theme/html5-boilerplate/README.md +0 -61
  93. data/theme/html5-boilerplate/apple-touch-icon-precomposed.png +0 -0
  94. data/theme/html5-boilerplate/crossdomain.xml +0 -15
  95. data/theme/html5-boilerplate/css/main.css +0 -297
  96. data/theme/html5-boilerplate/css/normalize.css +0 -527
  97. data/theme/html5-boilerplate/favicon.ico +0 -0
  98. data/theme/html5-boilerplate/humans.txt +0 -15
  99. data/theme/html5-boilerplate/img/.gitignore +0 -0
  100. data/theme/html5-boilerplate/index.html +0 -91
  101. data/theme/html5-boilerplate/js/main.js +0 -1
  102. data/theme/html5-boilerplate/js/plugins.js +0 -24
  103. data/theme/html5-boilerplate/js/vendor/jquery-1.10.2.min.js +0 -6
  104. data/theme/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js +0 -4
  105. data/theme/html5-boilerplate/post.html +0 -70
  106. data/theme/html5-boilerplate/robots.txt +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa18d35891eb1c5b91441efe68e7af906f76b6fe
4
- data.tar.gz: 36bc4253c45dc12535cdabf6824312e024367a93
3
+ metadata.gz: 371ba9509dee381bd125dddb8b5e067363eaef64
4
+ data.tar.gz: db43ebedc42a7f46a4320069bd5a72c508e97a8b
5
5
  SHA512:
6
- metadata.gz: 24b689ce00659c8dc99205aa1f01df9c01e7a98b2a971d1a4a08c6ad445e66fcbc60f6e2d09b455e81ea3cc255370b8a6df16b7652d21672c848d676ef09d253
7
- data.tar.gz: 3a20b4d425daf515dfb6f7a851fba5a09aa242e85bb720496d758bee2602c462b21decfb6401aaa5ae79b79fa0e431cf505d200e7f3ede0a9ec643780aaa71a7
6
+ metadata.gz: 49cf6a36dff404c7528d21fc75dae9bb6c93309b713f33d089e6c699085ffc5340e6807d49c097e4af17aed52f8c61cd3f52e04439b84a3c2fddaeb6b6022739
7
+ data.tar.gz: e58978c63dab9bef2fcbab9a45fba7cde34c439daa516ae5132fe8323fad7841ca84f55ceed1906c112b65bc015213704ca53cd10ad979b5c14b42771af9225d
data/.gitignore CHANGED
@@ -1,21 +1,9 @@
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
- .rvmrc
19
- .ruby-version
20
- .ruby-gemset
21
- *.sh
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://ruby.taobao.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in write_down.gemspec
4
4
  gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2013 Ma Lucheng
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2015 马陆骋
4
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:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
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.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # WriteDown
2
2
 
3
- yet another static blog generator
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/write_down`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
4
6
 
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
9
- gem 'write_down'
11
+ ```ruby
12
+ gem 'write_down'
13
+ ```
10
14
 
11
15
  And then execute:
12
16
 
@@ -18,12 +22,20 @@ Or install it yourself as:
18
22
 
19
23
  ## Usage
20
24
 
21
- $ write_down source dist
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec write_down` to use the gem in this directory, ignoring other installed copies of this gem.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
22
32
 
23
33
  ## Contributing
24
34
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/write_down.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "write_down"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/write_down ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "write_down"
@@ -0,0 +1,18 @@
1
+
2
+
3
+ module WriteDown
4
+ module Converter
5
+ # 基类, 定义了一些接口
6
+ class Base
7
+
8
+ def initialize(model)
9
+ @content = model.content
10
+ end
11
+
12
+ def render
13
+ raise "Not impl..."
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'pandoc-ruby'
2
+
3
+ module WriteDown
4
+ module Converter
5
+ # 基类, 定义了一些接口
6
+ class Markdown < Base
7
+
8
+ def initialize(model)
9
+ @content = model.content
10
+ end
11
+
12
+ def render
13
+ PandocRuby.convert(@content, { f: :markdown, to: :html5}, 'no-highlight').to_s
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'pandoc-ruby'
2
+
3
+ module WriteDown
4
+ module Converter
5
+ # 基类, 定义了一些接口
6
+ class Org < Base
7
+
8
+ def initialize(model)
9
+ @content = model.content
10
+ end
11
+
12
+ def render
13
+ PandocRuby.convert(@content, { f: :org, to: :html5}, 'no-highlight')
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ <!-- 首页的模板 -->
2
+
3
+ <h1>
4
+ <a href="/">编程青年</a>
5
+ </h1>
6
+ <section itemscope="" itemtype="http://schema.org/Blog">
7
+ <% items.each do |item| %>
8
+ <% unless item.draft %>
9
+ <article class="blog-article" itemscope="" itemtype="http://schema.org/BlogPosting">
10
+ <h2 class="blog-listing-title" itemprop="name">
11
+ <a href="/<%= item.link_to %>" itemprop="url">
12
+ <%= item.title %>
13
+ </a>
14
+ </h2>
15
+ <time class="blog-article-publishdate blog-listing-publishdate" content="<%= item.created_at %>" datetime="<%= item.created_at %>" itemprop="datePublished" pubdate=""><%= item.created_at %></time>
16
+ </article>
17
+ <% end %>
18
+ <% end %>
19
+ </section>
@@ -0,0 +1,5 @@
1
+ <!-- 文章视图 -->
2
+
3
+ <article class="main">
4
+ <%= body %>
5
+ </article>
@@ -0,0 +1,64 @@
1
+ <!doctype html>
2
+ <html lang="zh-cmn-Hans">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= title %></title>
6
+ <meta name="description" content="编程青年的博客,记录着软件开发中的点点滴滴">
7
+ <meta name="copyright" content="Ma Lucheng 2014-2015">
8
+ <meta name="generator" content="pandoc">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+
11
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
12
+ <link rel="icon" href="/favicon.ico" type="image/x-icon">
13
+ <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
14
+ <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
15
+ <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
16
+ <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
17
+ <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
18
+ <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
19
+ <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
20
+ <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
21
+ <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
22
+ <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
23
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
24
+ <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
25
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
26
+ <link rel="manifest" href="/manifest.json">
27
+ <meta name="msapplication-TileColor" content="#ffffff">
28
+ <meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
29
+ <meta name="theme-color" content="#ffffff">
30
+
31
+ <link href="/css/app.css<%= assets_version %>" rel="stylesheet">
32
+ </head>
33
+
34
+ <body>
35
+ <main id="content" role="main" class="row-wrapper">
36
+ <%= yield %>
37
+ </main> <!-- 网页主体 -->
38
+
39
+ <footer role="contentinfo" class="page-footer">
40
+ <p>© Ma Lucheng 2014-2015 — All content is licensed under the <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons BY-SA 3.0</a>.</p>
41
+ <nav>
42
+ <ul class="navigation-footer">
43
+ <% menus.each do |menu| %>
44
+ <li class="<%= menu[0] %>">
45
+ <a href="<%= menu[1] %>"><%= menu[0] %></a>
46
+ </li>
47
+ <% end %>
48
+ </ul>
49
+ <!-- <ul class="navigation-footer">
50
+ <% friend_links.each do |link| %>
51
+ <li>
52
+ <a href="<%= link[1] %>"><%= link[0] %></a>
53
+ </li>
54
+ <% end %>
55
+ </ul> -->
56
+ </nav>
57
+ <img src="/assets/images/home/zhifuma.png" />
58
+ </footer><!-- 页脚 -->
59
+
60
+ <script src="/js/vendor.js<%= assets_version %>"></script>
61
+ <script src="/js/app.js<%= assets_version %>"></script>
62
+ <script>require('main').init();</script>
63
+ </body>
64
+ </html>
@@ -0,0 +1,4 @@
1
+ <!-- 文章视图 -->
2
+ <article class="main page">
3
+ <%= body %>
4
+ </article>
@@ -0,0 +1,5 @@
1
+ <!-- 文章视图 -->
2
+
3
+ <article class="main">
4
+ <%= body %>
5
+ </article>
@@ -0,0 +1,79 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>reveal.js - The HTML Presentation Framework</title>
6
+ <meta name="description" content="A framework for easily creating beautiful presentations using HTML">
7
+ <meta name="author" content="Hakim El Hattab">
8
+ <meta name="apple-mobile-web-app-capable" content="yes" />
9
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
11
+
12
+ <link rel="stylesheet" href="<%=prefix%>css/reveal.css">
13
+ <link rel="stylesheet" href="<%=prefix%>css/theme/black.css" id="theme">
14
+ <!-- Code syntax highlighting -->
15
+ <link rel="stylesheet" href="<%=prefix%>lib/css/zenburn.css">
16
+
17
+ <!-- Printing and PDF exports -->
18
+ <script>
19
+ var link = document.createElement( 'link' );
20
+ link.rel = 'stylesheet';
21
+ link.type = 'text/css';
22
+ link.href = window.location.search.match( /print-pdf/gi ) ? '<%=prefix%>css/print/pdf.css' : '<%=prefix%>css/print/paper.css';
23
+ document.getElementsByTagName( 'head' )[0].appendChild( link );
24
+ </script>
25
+
26
+ <!--[if lt IE 9]>
27
+ <script src="<%=prefix%>lib/js/html5shiv.js"></script>
28
+ <![endif]-->
29
+ </head>
30
+
31
+ <body>
32
+
33
+ <div class="reveal">
34
+
35
+ <!-- Any section element inside of this container is displayed as a slide -->
36
+ <div class="slides" id="main-container">
37
+ <%= body %>
38
+ </div>
39
+
40
+ </div>
41
+
42
+ <!-- hook html struct -->
43
+ <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
44
+ <script src="<%=prefix%>org-adapter.js"></script>
45
+ <script>
46
+ // for #main-container
47
+ revealjs_adapter();
48
+ </script>
49
+
50
+ <script src="<%=prefix%>lib/js/head.min.js"></script>
51
+ <script src="<%=prefix%>js/reveal.js"></script>
52
+
53
+ <script>
54
+
55
+ // Full list of configuration options available at:
56
+ // https://github.com/hakimel/reveal.js#configuration
57
+ Reveal.initialize({
58
+ controls: true,
59
+ progress: true,
60
+ history: true,
61
+ center: true,
62
+
63
+ transition: 'slide', // none/fade/slide/convex/concave/zoom
64
+
65
+ // Optional reveal.js plugins
66
+ dependencies: [
67
+ { src: '<%=prefix%>lib/js/classList.js', condition: function() { return !document.body.classList; } },
68
+ { src: '<%=prefix%>plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
69
+ { src: '<%=prefix%>plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
70
+ { src: '<%=prefix%>plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
71
+ { src: '<%=prefix%>plugin/zoom-js/zoom.js', async: true },
72
+ { src: '<%=prefix%>plugin/notes/notes.js', async: true }
73
+ ]
74
+ });
75
+
76
+ </script>
77
+
78
+ </body>
79
+ </html>
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ require 'pathname'
3
+
4
+ module WriteDown
5
+ module Model
6
+ # 代表 js, css, 图片等资产
7
+ class Asset
8
+
9
+ def initialize(source_file, target_file = nil, option = {})
10
+ @source_file = source_file
11
+ @base_name = source_file.split("/").last.split(".").first
12
+ @ext_name = source_file.split("/").last.split(".").last
13
+ if target_file
14
+ @target_file = target_file
15
+ else
16
+ @target_file = "dist/#{target_file}"
17
+ end
18
+ @option = option
19
+ end
20
+
21
+ def build
22
+ hash_file_name = "#{@base_name}-#{Time.now.to_s}.#{@ext_name}"
23
+ output = Pathname.new("#{@target_file}")
24
+ output.dirname.mkpath
25
+ @final_path = @source_file.gsub("#{@base_name}.#{@ext_name}", hash_file_name)
26
+ `cp #{source_file} #{@final_path}`
27
+ end
28
+
29
+ def sync
30
+ # TODO 使用配置文件传入七牛的 key 和 secret
31
+ QiniuSync.new("", "").sync @final_path #TODO @final_path 放在 initialize 里
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,63 @@
1
+ require 'front_matter_parser'
2
+
3
+ module WriteDown
4
+ module Model
5
+ # 基类, 定义了一些接口
6
+ class Base
7
+
8
+ attr_accessor :draft
9
+ attr_accessor :created_at
10
+ attr_accessor :link_to
11
+ attr_accessor :content
12
+
13
+ def initialize(source_file, target_file = nil)
14
+ @source_file = source_file
15
+ @base_name = source_file.split("/").last.split(".").first
16
+ @ext_name = source_file.split("/").last.split(".").last
17
+ meta_file = File.join("source", "meta", "#{@base_name}.json")
18
+ @meta = File.exist?(meta_file) ? JSON.parse(File.open(meta_file).read) : read_from_head
19
+ @draft = @meta['draft'].to_s == "true" ? true : false
20
+ @created_at = @meta['date'] || File.open(@source_file).ctime #.iso8610
21
+ @content = File.open(@source_file).read
22
+ if target_file
23
+ @target_file = target_file
24
+ elsif @base_name.end_with?"index"
25
+ @target_file = "dist/#{@base_name}.html"
26
+ else
27
+ @target_file = "dist/#{@base_name}/index.html"
28
+ end
29
+ @link_to = @target_file.gsub("index.html", "")
30
+ end
31
+
32
+ def converter
33
+ if @ext_name == "md" || @ext_name == "markdown"
34
+ return WriteDown::Converter::Markdown
35
+ end
36
+ if @ext_name == "org"
37
+ return WriteDown::Converter::Org
38
+ end
39
+ end
40
+
41
+ def body
42
+ # binding.pry
43
+ converter.new(self).render
44
+ end
45
+
46
+ # 接口 render
47
+ # 用于找到自己的 erb 然后生成 html 字符串
48
+ def render
49
+ raise "Not impl..."
50
+ end
51
+
52
+ # 接口 build
53
+ # 用于把自己序列化到磁盘上
54
+ def build
55
+ raise "Not impl..."
56
+ end
57
+
58
+ def read_from_head
59
+ FrontMatterParser.parse_file(@source_file).front_matter
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,35 @@
1
+ require 'front_matter_parser'
2
+
3
+
4
+ module WriteDown
5
+ module Model
6
+
7
+ # 基类, 定义了一些接口
8
+ class Container
9
+
10
+ attr_accessor :items
11
+
12
+ def initialize(target_file, options = {})
13
+ @target_file = target_file
14
+ @items = []
15
+ @options = options
16
+ end
17
+
18
+ def render
19
+ template_file = File.expand_path('../../erb/container.erb', __FILE__)
20
+ template = File.read(template_file)
21
+ html_string = ERB.new(template).result(binding)
22
+ end
23
+
24
+ def build
25
+ Layout.new(self, @target_file, @options).render
26
+ self
27
+ end
28
+
29
+ def append(item)
30
+ @items << item
31
+ self
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ require 'pathname'
3
+ require 'date'
4
+ require 'json'
5
+ require 'time'
6
+
7
+ module WriteDown
8
+ module Model
9
+ # 代表散文
10
+ class Essay < Base
11
+
12
+ def render
13
+ template_file = File.expand_path('../../erb/essay.erb', __FILE__)
14
+ template = File.read(template_file)
15
+ html_string = ERB.new(template).result(binding)
16
+ html_string
17
+ end
18
+
19
+ def build
20
+ Layout.new(self, @target_file).render
21
+ self
22
+ end
23
+
24
+ # 概览
25
+ def summary
26
+ @meta['summary']
27
+ end
28
+
29
+ # 标题
30
+ def title
31
+ @meta['title']
32
+ end
33
+ end
34
+ end
35
+ end