persona 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/persona.rb +1 -12
- data/lib/persona/post.rb +13 -1
- data/lib/persona/version.rb +1 -1
- metadata +3 -3
data/lib/persona.rb
CHANGED
@@ -11,7 +11,7 @@ autoload :Page, 'persona/page'
|
|
11
11
|
#ROUTES
|
12
12
|
|
13
13
|
get '/' do
|
14
|
-
@posts =
|
14
|
+
@posts = Post.all
|
15
15
|
erb :index
|
16
16
|
end
|
17
17
|
|
@@ -64,14 +64,3 @@ not_found do
|
|
64
64
|
erb :not_found
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
def load_posts
|
69
|
-
posts = Dir.entries('./contents/posts').sort.reverse.reject do |it|
|
70
|
-
not it.end_with? '.txt'
|
71
|
-
end
|
72
|
-
|
73
|
-
posts.map do |it|
|
74
|
-
Post.new it
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
data/lib/persona/post.rb
CHANGED
@@ -2,8 +2,10 @@ class Post
|
|
2
2
|
|
3
3
|
attr_reader :content, :title, :author, :url, :date, :excerpt, :is_excerpt
|
4
4
|
|
5
|
+
POST_FOLDER = './contents/posts'
|
6
|
+
|
5
7
|
def initialize(file_name)
|
6
|
-
f = File.open("
|
8
|
+
f = File.open("#{POST_FOLDER}/#{file_name}","r")
|
7
9
|
@content = f.content_as_string
|
8
10
|
@title = f.metadata 'title'
|
9
11
|
@author = f.metadata 'author'
|
@@ -22,6 +24,16 @@ class Post
|
|
22
24
|
Post.new "#{y}-#{m}-#{d}-#{name}.txt"
|
23
25
|
end
|
24
26
|
|
27
|
+
def self.all
|
28
|
+
posts = Dir.entries("#{POST_FOLDER}").sort.reverse.reject do |it|
|
29
|
+
not it.end_with? '.txt'
|
30
|
+
end
|
31
|
+
|
32
|
+
posts.map do |it|
|
33
|
+
Post.new it
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
25
37
|
private
|
26
38
|
|
27
39
|
MORE_TAG = '<!--more-->'
|
data/lib/persona/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Filippo Diotalevi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-27 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|