File tree 2 files changed +4
-2
lines changed
2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ Dotenv.load
12
12
require_relative 'lib/transformative.rb'
13
13
14
14
DB = Sequel . connect ( ENV [ 'DATABASE_URL' ] )
15
- DB [ :posts ] . truncate
16
15
17
16
CONTENT_PATH = "#{ File . dirname ( __FILE__ ) } /../content"
18
17
28
27
29
28
desc "Rebuild database cache from all content JSON files."
30
29
task :rebuild do
30
+ DB [ :posts ] . truncate
31
31
Dir . glob ( "#{ CONTENT_PATH } /**/*.json" ) . each do |file |
32
32
parse ( file )
33
33
end
34
34
end
35
35
36
36
desc "Rebuild database cache from this month's content JSON files."
37
37
task :recent do
38
+ DB [ :posts ] . truncate
38
39
year_month = Time . now . strftime ( '%Y/%m' )
39
40
files = Dir . glob ( "#{ CONTENT_PATH } /#{ year_month } /**/*.json" )
40
41
# need to rebuild all cites and cards because they're not organised by month
Original file line number Diff line number Diff line change @@ -42,9 +42,10 @@ def parse_mf2(url)
42
42
published = properties . key? ( 'published' ) ?
43
43
Time . parse ( properties [ 'published' ] [ 0 ] ) : Time . now
44
44
post_url = properties . key? ( 'url' ) ? properties [ 'url' ] [ 0 ] : url
45
+ post_name = properties . key? ( 'name' ) ? properties [ 'name' ] [ 0 ] . strip : ''
45
46
hash = {
46
47
'url' => [ URI . join ( url , post_url ) . to_s ] ,
47
- 'name' => [ properties [ 'name' ] [ 0 ] . strip ] ,
48
+ 'name' => [ post_name ] ,
48
49
'published' => [ published . utc . iso8601 ] ,
49
50
'content' => [ properties [ 'content' ] [ 0 ] [ 'value' ] ] ,
50
51
'author' => [ author . properties [ 'url' ] [ 0 ] ]
You can’t perform that action at this time.
0 commit comments