artifact 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/bin/artifact +1 -1
- data/lib/artifact.rb +43 -1
- data/lib/artifact/cli.rb +12 -0
- data/lib/artifact/middleman.rb +10 -1
- data/lib/artifact/version.rb +1 -1
- data/lib/artifact/views/layout.erb +1 -1
- data/lib/artifact/views/posts/edit.erb +1 -0
- data/lib/artifact/views/posts/index.erb +4 -0
- data/scaffold/Gemfile +6 -0
- data/scaffold/config.ru +29 -0
- data/scaffold/source/layout.html +7 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6c17de9ae37b3707264d2f62414ed0fe9f8e9c
|
4
|
+
data.tar.gz: fcb141f55a2c48dfe223adea3ab46bec98bec9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d87193120f88d5d5a4b8bf8985fa4e62484836edfcc8ff8f0af29f1692fd7b952623ac83721c6f601248d280d39068ca75bd41551cc1735ad78747368c30455
|
7
|
+
data.tar.gz: fe4094136b744706f109e7096b0d9e60dbe1eeadab3d738ab400558ba7c57e94eae8cb2d7b272feca9534e896d3dab0b7a929f66a585eb3705b97b2501f50a2e
|
data/LICENSE.txt
CHANGED
data/bin/artifact
CHANGED
data/lib/artifact.rb
CHANGED
@@ -69,7 +69,7 @@ module Artifact
|
|
69
69
|
attr_accessor *%w(
|
70
70
|
root source_root posts_path drafts_path uploads_path
|
71
71
|
directory_indexes rebuild_args author_name author_email
|
72
|
-
before_update after_update
|
72
|
+
before_update after_update before_push after_push
|
73
73
|
)
|
74
74
|
|
75
75
|
def initialize
|
@@ -147,6 +147,8 @@ module Artifact
|
|
147
147
|
|
148
148
|
class Repo
|
149
149
|
|
150
|
+
class SyncError < RuntimeError; end
|
151
|
+
|
150
152
|
def initialize(full_path)
|
151
153
|
@root = full_path
|
152
154
|
@git = Rugged::Repository.new(full_path)
|
@@ -187,6 +189,13 @@ module Artifact
|
|
187
189
|
!!file_status(path) rescue false
|
188
190
|
end
|
189
191
|
|
192
|
+
def sync!
|
193
|
+
code, out = pull
|
194
|
+
raise SyncError.new("Error when pulling changes: #{out.strip}") unless code == 0
|
195
|
+
code, out = push
|
196
|
+
raise SyncError.new("Error when pushing changes: #{out.strip}") unless code == 0
|
197
|
+
end
|
198
|
+
|
190
199
|
private
|
191
200
|
|
192
201
|
def new_file?(file_path)
|
@@ -206,6 +215,8 @@ module Artifact
|
|
206
215
|
# the author signature is a Hash containing :name, :email of the author
|
207
216
|
# and :time of the change.
|
208
217
|
def write_commit(message, author)
|
218
|
+
Artifact.run_hook(:before_commit, message)
|
219
|
+
|
209
220
|
author[:time] = Time.now
|
210
221
|
commit_sha = Rugged::Commit.create(@git,
|
211
222
|
:author => author,
|
@@ -215,6 +226,37 @@ module Artifact
|
|
215
226
|
:tree => @git.index.write_tree,
|
216
227
|
:update_ref => 'HEAD'
|
217
228
|
)
|
229
|
+
|
230
|
+
Artifact.run_hook(:after_commit, message)
|
231
|
+
end
|
232
|
+
|
233
|
+
def pull
|
234
|
+
# updated = false
|
235
|
+
code, out = nil, nil
|
236
|
+
Dir.chdir(@root) do
|
237
|
+
out = `git pull --rebase`
|
238
|
+
code = $?
|
239
|
+
# updated = out.strip != 'Current branch master is up to date.'
|
240
|
+
# updated = res.strip != 'Already up-to-date.'
|
241
|
+
end
|
242
|
+
# updated
|
243
|
+
return code, out
|
244
|
+
end
|
245
|
+
|
246
|
+
def push
|
247
|
+
Artifact.run_hook(:before_push)
|
248
|
+
|
249
|
+
# updated = false
|
250
|
+
code, out = nil, nil
|
251
|
+
Dir.chdir(@root) do
|
252
|
+
out = `git push`
|
253
|
+
code = $?
|
254
|
+
# updated = out.strip != 'Everything up-to-date'
|
255
|
+
end
|
256
|
+
|
257
|
+
Artifact.run_hook(:after_push)
|
258
|
+
# updated
|
259
|
+
return code, out
|
218
260
|
end
|
219
261
|
|
220
262
|
end
|
data/lib/artifact/cli.rb
ADDED
data/lib/artifact/middleman.rb
CHANGED
@@ -67,6 +67,15 @@ module Artifact
|
|
67
67
|
redirect to('/')
|
68
68
|
end
|
69
69
|
|
70
|
+
post '/sync' do
|
71
|
+
begin
|
72
|
+
Artifact.repo.sync!
|
73
|
+
redirect to('/')
|
74
|
+
rescue Artifact::Repo::SyncError => e
|
75
|
+
redirect to('/?error=' + e.message)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
70
79
|
get '/search' do
|
71
80
|
if params[:q].present?
|
72
81
|
normalized = params[:q].gsub(' ', '-').downcase
|
@@ -241,7 +250,7 @@ module Artifact
|
|
241
250
|
Artifact.middleman.sitemap.rebuild_resource_list!
|
242
251
|
|
243
252
|
if Artifact.middleman.extensions[:frontmatter]
|
244
|
-
puts "Flushing frontmatter cache..."
|
253
|
+
# puts "Flushing frontmatter cache..."
|
245
254
|
Artifact.middleman.extensions[:frontmatter].flush_cache!
|
246
255
|
end
|
247
256
|
end
|
data/lib/artifact/version.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
<meta name="author" content="Fork Ltd.">
|
13
13
|
|
14
14
|
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
15
|
-
|
15
|
+
<link href='http://fonts.googleapis.com/css?family=Lato:300,900|Asap|Titillium+Web' rel='stylesheet' type='text/css' />
|
16
16
|
<link rel="stylesheet" href="http://tomas.github.io/base.css/build/base-min.css" type="text/css" media="screen" />
|
17
17
|
<link rel="stylesheet" href="<%= url('/css/main.css') %>" type="text/css" media="screen" charset="utf-8" />
|
18
18
|
|
@@ -7,6 +7,10 @@
|
|
7
7
|
<ul class="right menu menu-horizontal">
|
8
8
|
<li><a target="_blank" class="btn" href="/">View site</a></li>
|
9
9
|
|
10
|
+
<form method="post" class="inline" action="<%= url('/sync') %>">
|
11
|
+
<li><button class="btn btn-success" type="submit">Sync repo</button></li>
|
12
|
+
</form>
|
13
|
+
|
10
14
|
<form method="post" class="inline" action="<%= url('/build') %>">
|
11
15
|
<li><button class="btn btn-danger" type="submit">Rebuild!</button></li>
|
12
16
|
</form>
|
data/scaffold/Gemfile
ADDED
data/scaffold/config.ru
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# you would normally run this only on development
|
2
|
+
# then upload and rebuild your website using `bundle exec middleman build`
|
3
|
+
|
4
|
+
# require 'bundler/setup'
|
5
|
+
require 'middleman'
|
6
|
+
require 'middleman-blog'
|
7
|
+
|
8
|
+
require 'artifact'
|
9
|
+
require 'artifact/middleman'
|
10
|
+
|
11
|
+
# all available options for artifact
|
12
|
+
Artifact.configure do |config|
|
13
|
+
config.source_root = 'source' # everything else should be under this dir
|
14
|
+
config.uploads_path = 'uploads'
|
15
|
+
config.drafts_path = 'drafts'
|
16
|
+
config.posts_path = 'posts'
|
17
|
+
config.author_name = 'Your Name'
|
18
|
+
config.author_email = 'your@email.com'
|
19
|
+
config.rebuild_args = '--no-clean'
|
20
|
+
end
|
21
|
+
|
22
|
+
map('/admin') do
|
23
|
+
run Artifact::Middleman
|
24
|
+
end
|
25
|
+
|
26
|
+
map('/') do
|
27
|
+
use WhateverMiddleware
|
28
|
+
run Middleman::Application.server # so we can see the live website
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artifact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- bin/artifact
|
126
126
|
- lib/artifact.rb
|
127
127
|
- lib/artifact/app.rb
|
128
|
+
- lib/artifact/cli.rb
|
128
129
|
- lib/artifact/files.rb
|
129
130
|
- lib/artifact/helpers.rb
|
130
131
|
- lib/artifact/middleman.rb
|
@@ -151,6 +152,9 @@ files:
|
|
151
152
|
- lib/artifact/views/shared/_menu.erb
|
152
153
|
- lib/artifact/views/uploads/_form.erb
|
153
154
|
- lib/artifact/views/uploads/_list.erb
|
155
|
+
- scaffold/Gemfile
|
156
|
+
- scaffold/config.ru
|
157
|
+
- scaffold/source/layout.html
|
154
158
|
homepage: ''
|
155
159
|
licenses:
|
156
160
|
- MIT
|
@@ -171,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
175
|
version: '0'
|
172
176
|
requirements: []
|
173
177
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.4.5
|
175
179
|
signing_key:
|
176
180
|
specification_version: 4
|
177
181
|
summary: Frontend UI for git blogging.
|
178
182
|
test_files: []
|
179
|
-
has_rdoc:
|