blogue 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a505062d8b893b86710be42e7cb204f57ba97875
4
- data.tar.gz: 56d0545a6467270da541208b03b045e39b78ec7b
3
+ metadata.gz: 99a1b18f0e77e2213458bba2e7f20a720d38e9df
4
+ data.tar.gz: 15188b23ea69249bb5af6069c2c4b9caf7ce4c5d
5
5
  SHA512:
6
- metadata.gz: 53fd19e403ba6c0cbe77b4c02fc801e8a86e1db055486781277945f302dccaf419f1c93b99524f909a1d06e06763f681d9816f059d50648e6e3fd2d995f5a699
7
- data.tar.gz: 27d788f14d0c01486e2488f9fe9bd850d17da1509896f38fd3681aee89df905e3f5f2cc4e60dabc120ce48b35a1c1a392bbeb131cbf07056f7c610a3580c4fd4
6
+ metadata.gz: 2829448805a1711dfbeaf811d01d746c0ed148e0499706c3cee9cff683b43ddb77a633f7d0a0d79c50b03889d12428b64ffe5dcfcf843f476307d8860aef33c0
7
+ data.tar.gz: ddc82555f1a6a662e15a4aa66407bc0c68b1024e008271f708a0b9a0ffa8d321ca3f8a6437cd75d9fc921abc617da9a654ef940fb42fd1c39b4999beff9d40ae
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Blogue
2
2
 
3
- Blogue is the static page blog that is also a rails engine. It means that you get all of rails, yet your blog is static. Best of both worlds.
3
+ [![Build Status](https://api.travis-ci.org/maxim/blogue.png)](https://travis-ci.org/maxim/blogue)
4
+
5
+ Blogue is a rails model for static blog posts, wrapped in an engine. It means that you can have blog posts as static files (kind of like views) inside your rails app, and hook up posts like any other resource. The only reason this is an engine and not just a class in a gem is because it also adds an asset path and a handler for .md views.
4
6
 
5
7
  ## What you get
6
8
 
@@ -14,41 +16,46 @@ Blogue is the static page blog that is also a rails engine. It means that you ge
14
16
  * Default controllers
15
17
  * Default views
16
18
  * Generators
19
+ * Comments, tags or pretty much any functionality
17
20
 
18
- You just hook it up by hand any way you want.
21
+ There are thousands of gems that you can pick from to do that stuff.
19
22
 
20
23
  ## Usage
21
24
 
22
25
  1. Generate a rails app (or use existing)
23
- 2. Add `gem 'blogue'` to Gemfile and bundle
24
- 3. Create a model `app/models/post.rb` (the name 'Post' is chosen at random)
26
+ 2. Add all needed gems to Gemfile and bundle
25
27
  ~~~ruby
26
- class Post < Blogue::Post
27
- # Here you can override inherited methods any way you like.
28
- # See app/models/blogue/post.rb to see what you have
29
- end
28
+ gem 'kramdown'
29
+ gem 'rouge'
30
+ gem 'blogue'
30
31
  ~~~
31
32
 
32
- 4. Create a controller `app/controllers/posts_controller.rb`
33
+ 3. Create a model `app/models/post.rb` (the name 'Post' is chosen at random)
33
34
  ~~~ruby
34
- class PostsController < ApplicationController
35
- def index
36
- @posts = Post.all
35
+ class Post < Blogue::Post
36
+ # Here you can override inherited methods any way you like.
37
+ # See app/models/blogue/post.rb to see what you have
37
38
  end
39
+ ~~~
38
40
 
39
- def show
40
- @post = Post.find(id)
41
+ 4. Create a controller `app/controllers/posts_controller.rb`
42
+ ~~~ruby
43
+ class PostsController < ApplicationController
44
+ def index
45
+ @posts = Post.all
46
+ end
47
+
48
+ def show
49
+ @post = Post.find(params[:id]) ||
50
+ raise(ActionController::RoutingError.new('Not Found'))
51
+ end
41
52
  end
42
- end
43
53
  ~~~
44
54
 
45
55
  5. Add a route to your `config/routes.rb` like this
46
56
  ~~~ruby
47
- # If you want an index page
48
- root to: 'posts#index'
49
-
50
- # Whitelist of your posts
51
- Post.all.each { |post| get "/#{post.id}", to: 'posts#show', id: post.id }
57
+ root to: 'posts#index' # if you want an index page
58
+ get '/:id', to: 'posts#show'
52
59
  ~~~
53
60
 
54
61
  6. Add `app/views/posts/index.html.erb` for your index page
@@ -68,32 +75,32 @@ You just hook it up by hand any way you want.
68
75
 
69
76
  7. Add `app/views/posts/show.html.erb` for your post page
70
77
  ~~~erb
71
- <%= link_to 'index', root_path %>
78
+ <%= link_to 'index', root_path %>
72
79
 
73
- <%=raw render file: @post.path %>
80
+ <%=raw render file: @post.path %>
74
81
 
75
- <% if @post.date %>
76
- <p>Published on <%= @post.date.to_s(:long) %></p>
77
- <% end %>
82
+ <% if @post.date %>
83
+ <p>Published on <%= @post.date.to_s(:long) %></p>
84
+ <% end %>
78
85
  ~~~
79
86
 
80
87
  8. Create a directory `app/posts` (that's default location of posts)
81
88
  9. Create a directory `app/posts/assets` (it's added to assets paths by default)
82
89
  10. Add a post like `app/posts/my-first-post.md`
83
- ~~~markdown
84
- # Yay my first post
85
90
 
86
- This is some text.
91
+ # Yay my first post
87
92
 
88
- ![picture](/assets/picture.jpg)
93
+ This is some text.
89
94
 
90
- ~~~ruby
91
- foo = 'foo' # a codeblock
92
- ~~~
95
+ ![picture](/assets/picture.jpg)
96
+
97
+ ~~~ruby
98
+ foo = 'foo' # a codeblock
99
+ ~~~
100
+
101
+ <!--meta
102
+ date: 2013-10-21
103
+ tldr: Awesome
104
+ -->
93
105
 
94
- <!--meta
95
- date: 2013-10-21
96
- tldr: Awesome
97
- -->
98
- ~~~
99
106
  11. Start server and go to http://localhost:3000/my-first-post
@@ -60,6 +60,10 @@ module Blogue
60
60
  meta['tldr']
61
61
  end
62
62
 
63
+ def author_name
64
+ meta_author_name || config_author_name || whoami_author_name
65
+ end
66
+
63
67
  def meta
64
68
  YAML.load(
65
69
  body.lines.select do |line|
@@ -101,5 +105,17 @@ module Blogue
101
105
  def filename_title
102
106
  id.split(/[-_]/).join(' ').capitalize
103
107
  end
108
+
109
+ def meta_author_name
110
+ meta['author']
111
+ end
112
+
113
+ def config_author_name
114
+ Blogue.author_name
115
+ end
116
+
117
+ def whoami_author_name
118
+ `whoami`.strip
119
+ end
104
120
  end
105
121
  end
@@ -1,3 +1,3 @@
1
1
  module Blogue
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/blogue.rb CHANGED
@@ -5,6 +5,7 @@ module Blogue
5
5
  mattr_accessor :assets_path
6
6
  mattr_accessor :markdown_format_handler
7
7
  mattr_accessor :kramdown_codeblock_handler
8
+ mattr_accessor :author_name
8
9
 
9
10
  self.posts_path = 'app/posts'
10
11
 
@@ -3726,3 +3726,99 @@ Started GET "/header-title" for 127.0.0.1 at 2013-10-21 00:00:25 -0400
3726
3726
  Processing by PostsController#show as HTML
3727
3727
  Parameters: {"id"=>"header-title"}
3728
3728
  Completed 200 OK in 8ms (Views: 6.3ms)
3729
+ -----------------------------------------------------
3730
+ Blogue::PostTest: test_date_returns_date_part_of_time
3731
+ -----------------------------------------------------
3732
+ ------------------------------------------------------------
3733
+ Blogue::PostTest: test_extract_post_id_extracts_id_from_path
3734
+ ------------------------------------------------------------
3735
+ -------------------------------------------------------------------------------------
3736
+ Blogue::PostTest: test_extract_post_id_extracts_id_from_path_with_multiple_extensions
3737
+ -------------------------------------------------------------------------------------
3738
+ ---------------------------------------
3739
+ Blogue::PostTest: test_finds_post_by_id
3740
+ ---------------------------------------
3741
+ -------------------------------------------------------------
3742
+ Blogue::PostTest: test_sort_posts_reverse-sorts_posts_by_time
3743
+ -------------------------------------------------------------
3744
+ ----------------------------------------------------------------
3745
+ Blogue::PostTest: test_uses_file_creation_time_when_no_meta_date
3746
+ ----------------------------------------------------------------
3747
+ -----------------------------------------------------------------------
3748
+ Blogue::PostTest: test_uses_filename_as_title_when_no_other_alternative
3749
+ -----------------------------------------------------------------------
3750
+ ---------------------------------------------------------------
3751
+ Blogue::PostTest: test_uses_markdown_header_as_title_if_present
3752
+ ---------------------------------------------------------------
3753
+ -------------------------------------------------
3754
+ Blogue::PostTest: test_uses_meta_title_if_present
3755
+ -------------------------------------------------
3756
+ -----------------------------------------------------
3757
+ Blogue::PostTest: test_uses_time_from_meta_when_given
3758
+ -----------------------------------------------------
3759
+ ---------------------------------------------------------------------
3760
+ ConfigurationTest: test_adds_[posts_path]/assets_to_rails_asset_paths
3761
+ ---------------------------------------------------------------------
3762
+ Started GET "/assets/dogue.jpg" for 127.0.0.1 at 2013-10-21 01:09:38 -0400
3763
+ -----------------------------------------------------
3764
+ ConfigurationTest: test_renders_codeblocks_with_rouge
3765
+ -----------------------------------------------------
3766
+ Started GET "/code-block" for 127.0.0.1 at 2013-10-21 01:09:38 -0400
3767
+ Processing by PostsController#show as HTML
3768
+ Parameters: {"id"=>"code-block"}
3769
+ Completed 200 OK in 66ms (Views: 63.3ms)
3770
+ ------------------------------------------------------
3771
+ ConfigurationTest: test_renders_markdown_with_kramdown
3772
+ ------------------------------------------------------
3773
+ Started GET "/header-title" for 127.0.0.1 at 2013-10-21 01:09:38 -0400
3774
+ Processing by PostsController#show as HTML
3775
+ Parameters: {"id"=>"header-title"}
3776
+ Completed 200 OK in 8ms (Views: 6.3ms)
3777
+ -----------------------------------------------------
3778
+ Blogue::PostTest: test_date_returns_date_part_of_time
3779
+ -----------------------------------------------------
3780
+ ------------------------------------------------------------
3781
+ Blogue::PostTest: test_extract_post_id_extracts_id_from_path
3782
+ ------------------------------------------------------------
3783
+ -------------------------------------------------------------------------------------
3784
+ Blogue::PostTest: test_extract_post_id_extracts_id_from_path_with_multiple_extensions
3785
+ -------------------------------------------------------------------------------------
3786
+ ---------------------------------------
3787
+ Blogue::PostTest: test_finds_post_by_id
3788
+ ---------------------------------------
3789
+ -------------------------------------------------------------
3790
+ Blogue::PostTest: test_sort_posts_reverse-sorts_posts_by_time
3791
+ -------------------------------------------------------------
3792
+ ----------------------------------------------------------------
3793
+ Blogue::PostTest: test_uses_file_creation_time_when_no_meta_date
3794
+ ----------------------------------------------------------------
3795
+ -----------------------------------------------------------------------
3796
+ Blogue::PostTest: test_uses_filename_as_title_when_no_other_alternative
3797
+ -----------------------------------------------------------------------
3798
+ ---------------------------------------------------------------
3799
+ Blogue::PostTest: test_uses_markdown_header_as_title_if_present
3800
+ ---------------------------------------------------------------
3801
+ -------------------------------------------------
3802
+ Blogue::PostTest: test_uses_meta_title_if_present
3803
+ -------------------------------------------------
3804
+ -----------------------------------------------------
3805
+ Blogue::PostTest: test_uses_time_from_meta_when_given
3806
+ -----------------------------------------------------
3807
+ ---------------------------------------------------------------------
3808
+ ConfigurationTest: test_adds_[posts_path]/assets_to_rails_asset_paths
3809
+ ---------------------------------------------------------------------
3810
+ Started GET "/assets/dogue.jpg" for 127.0.0.1 at 2013-10-21 01:10:00 -0400
3811
+ -----------------------------------------------------
3812
+ ConfigurationTest: test_renders_codeblocks_with_rouge
3813
+ -----------------------------------------------------
3814
+ Started GET "/code-block" for 127.0.0.1 at 2013-10-21 01:10:00 -0400
3815
+ Processing by PostsController#show as HTML
3816
+ Parameters: {"id"=>"code-block"}
3817
+ Completed 200 OK in 48ms (Views: 46.5ms)
3818
+ ------------------------------------------------------
3819
+ ConfigurationTest: test_renders_markdown_with_kramdown
3820
+ ------------------------------------------------------
3821
+ Started GET "/header-title" for 127.0.0.1 at 2013-10-21 01:10:00 -0400
3822
+ Processing by PostsController#show as HTML
3823
+ Parameters: {"id"=>"header-title"}
3824
+ Completed 200 OK in 7ms (Views: 5.7ms)
@@ -36,7 +36,7 @@ module Blogue
36
36
  end
37
37
 
38
38
  test 'uses file creation time when no meta date' do
39
- assert_equal '2013-10-19 19:54:41 UTC',
39
+ assert_equal File.ctime('test/fixtures/posts/minimal-post.md').utc.to_s,
40
40
  Post.find('minimal-post').time.utc.to_s
41
41
  end
42
42
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-21 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -125,7 +125,8 @@ files:
125
125
  - test/models/blogue/post_test.rb
126
126
  - test/test_helper.rb
127
127
  homepage: http://github.com/maxim/blogue
128
- licenses: []
128
+ licenses:
129
+ - MIT
129
130
  metadata: {}
130
131
  post_install_message:
131
132
  rdoc_options: []