ecrire 0.28.3 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Rakefile +22 -0
  4. data/lib/ecrire/app/assets/images/favicon.ico +0 -0
  5. data/lib/ecrire/app/assets/javascripts/admin/editor/content.coffee +3 -0
  6. data/lib/ecrire/app/assets/javascripts/admin/navigation/save.js.coffee +9 -2
  7. data/lib/ecrire/app/assets/javascripts/admin/posts/filter.js.coffee +19 -0
  8. data/lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee +15 -6
  9. data/lib/ecrire/app/assets/javascripts/admin/posts/header.coffee +17 -9
  10. data/lib/ecrire/app/assets/javascripts/admin/posts/list.coffee +6 -0
  11. data/lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee +39 -0
  12. data/lib/ecrire/app/assets/javascripts/admin/posts/tags/list.coffee +27 -0
  13. data/lib/ecrire/app/assets/javascripts/admin/posts/tags/tag.coffee +17 -0
  14. data/lib/ecrire/app/assets/javascripts/admin/posts/tags.coffee +11 -0
  15. data/lib/ecrire/app/assets/javascripts/admin/posts/title.coffee +6 -39
  16. data/lib/ecrire/app/assets/javascripts/admin/posts/titles.coffee +8 -0
  17. data/lib/ecrire/app/assets/javascripts/shared/popup.js.coffee +17 -4
  18. data/lib/ecrire/app/assets/stylesheets/admin/header.scss +126 -17
  19. data/lib/ecrire/app/assets/stylesheets/admin/navigation.scss +5 -1
  20. data/lib/ecrire/app/assets/stylesheets/admin/posts.scss +80 -281
  21. data/lib/ecrire/app/assets/stylesheets/admin/preview.scss +55 -0
  22. data/lib/ecrire/app/assets/stylesheets/admin/tags.scss +59 -0
  23. data/lib/ecrire/app/assets/stylesheets/admin/title.scss +79 -89
  24. data/lib/ecrire/app/assets/stylesheets/shared/popup.scss +4 -20
  25. data/lib/ecrire/app/assets/stylesheets/vendor/prism.scss +1 -0
  26. data/lib/ecrire/app/controllers/admin/posts/tags_controller.rb +30 -2
  27. data/lib/ecrire/app/controllers/admin/posts/titles_controller.rb +10 -5
  28. data/lib/ecrire/app/controllers/admin/posts_controller.rb +10 -10
  29. data/lib/ecrire/app/helpers/admin/posts_helper.rb +7 -3
  30. data/lib/ecrire/app/helpers/application_helper.rb +20 -0
  31. data/lib/ecrire/app/helpers/content_tag_helper.rb +4 -0
  32. data/lib/ecrire/app/models/admin/post.rb +23 -0
  33. data/lib/ecrire/app/models/post.rb +1 -1
  34. data/lib/ecrire/app/models/tag.rb +8 -0
  35. data/lib/ecrire/app/views/admin/posts/_post.html.erb +9 -0
  36. data/lib/ecrire/app/views/admin/posts/edit.html.erb +21 -61
  37. data/lib/ecrire/app/views/admin/posts/header/_base.html.erb +54 -0
  38. data/lib/ecrire/app/views/admin/posts/index.html.erb +52 -33
  39. data/lib/ecrire/app/views/admin/posts/index.js.erb +1 -1
  40. data/lib/ecrire/app/views/admin/posts/show.html.erb +5 -23
  41. data/lib/ecrire/app/views/admin/posts/tags/_tag.html.erb +11 -2
  42. data/lib/ecrire/app/views/admin/posts/tags/_tags.html.erb +12 -0
  43. data/lib/ecrire/app/views/admin/posts/tags/create.js.erb +2 -0
  44. data/lib/ecrire/app/views/admin/posts/tags/index.js.erb +1 -0
  45. data/lib/ecrire/app/views/admin/posts/tags/toggle.js.erb +2 -1
  46. data/lib/ecrire/app/views/admin/posts/titles/_form.html.erb +2 -2
  47. data/lib/ecrire/app/views/admin/posts/titles/_index.html.erb +10 -0
  48. data/lib/ecrire/app/views/admin/posts/titles/_titles.html.erb +6 -0
  49. data/lib/ecrire/app/views/admin/posts/titles/index.html.erb +2 -37
  50. data/lib/ecrire/app/views/admin/posts/titles/index.js.erb +2 -0
  51. data/lib/ecrire/app/views/admin/posts/titles/update.js.erb +1 -0
  52. data/lib/ecrire/app/views/admin/tags/_tags.html.erb +6 -10
  53. data/lib/ecrire/app/views/admin/tags/index.js.erb +1 -1
  54. data/lib/ecrire/app/views/layouts/admin/application.html.erb +1 -1
  55. data/lib/ecrire/application.rb +0 -2
  56. data/lib/ecrire/commands/console.rb +1 -1
  57. data/lib/ecrire/config/environment/development.rb +2 -0
  58. data/lib/ecrire/db/migrate/20140618321984_add_properties_to_posts.rb +1 -1
  59. data/lib/ecrire/onboarding/assets/stylesheets/shared/base.scss +11 -10
  60. data/lib/ecrire/onboarding/assets/stylesheets/shared/complete.scss +1 -0
  61. data/lib/ecrire/onboarding/assets/stylesheets/shared/welcome.scss +1 -1
  62. data/lib/ecrire/routes.rb +1 -1
  63. data/lib/ecrire/theme/template/assets/stylesheets/shared/{base.css.scss → base.scss} +4 -18
  64. data/lib/ecrire/theme/template/assets/stylesheets/shared/code.scss +33 -0
  65. data/lib/ecrire/theme/template/assets/stylesheets/shared/{header.css.scss → header.scss} +13 -3
  66. data/lib/ecrire/theme/template/assets/stylesheets/shared/{posts.css.scss → posts.scss} +10 -0
  67. data/lib/ecrire/theme/template/controllers/posts_controller.rb +0 -4
  68. data/lib/ecrire/theme/template/secrets.yml +4 -4
  69. data/lib/ecrire/theme/template/views/layouts/application.html.erb +2 -2
  70. data/lib/ecrire/version.rb +1 -1
  71. data/lib/ecrire.rb +1 -0
  72. data/test/editor/models/post_test.rb +1 -1
  73. data/test/theme/theme/views/layouts/application.html.erb +1 -0
  74. metadata +35 -18
  75. data/lib/ecrire/app/assets/javascripts/admin/posts/filters/filter.js.coffee +0 -21
  76. data/lib/ecrire/app/assets/javascripts/admin/posts/tag.js.coffee +0 -11
  77. data/lib/ecrire/app/views/admin/posts/_posts.html.erb +0 -26
  78. /data/lib/ecrire/app/assets/javascripts/admin/posts/{new.js.coffee → new.coffee} +0 -0
  79. /data/lib/ecrire/app/assets/javascripts/admin/posts/{toggle.js.coffee → toggle.coffee} +0 -0
  80. /data/lib/ecrire/theme/template/assets/stylesheets/browser/{base.css.scss → base.scss} +0 -0
  81. /data/lib/ecrire/theme/template/assets/stylesheets/{browser.css.scss → browser.scss} +0 -0
  82. /data/lib/ecrire/theme/template/assets/stylesheets/mobile/{base.css.scss → base.scss} +0 -0
  83. /data/lib/ecrire/theme/template/assets/stylesheets/{mobile.css.scss → mobile.scss} +0 -0
  84. /data/lib/ecrire/theme/template/assets/stylesheets/shared/{tags.css.scss → tags.scss} +0 -0
  85. /data/lib/ecrire/theme/template/assets/stylesheets/tablet/{base.css.scss → base.scss} +0 -0
  86. /data/lib/ecrire/theme/template/assets/stylesheets/{tablet.css.scss → tablet.scss} +0 -0
  87. /data/lib/ecrire/theme/template/assets/stylesheets/{variables.css.scss → variables.scss} +0 -0
@@ -1,116 +1,105 @@
1
- #TitlesIndex, #TitlesCreate {
2
-
3
- & > section {
4
-
5
- h3 {
6
- margin: 1em 0 0 0;
7
- }
8
-
9
- form {
10
- @include display(flex);
11
- @include align-items(flex-start);
12
- width: 100%;
13
- max-width: 500px;
14
- margin: 5em auto 0 auto;
15
- div.fieldset {
16
- @include display(flex);
17
- width: 100%;
18
- }
19
-
20
- & ~ p {
21
- max-width: 500px;
22
- width: 100%;
23
- margin: 0.3em 0 3em 0;
24
- font-size: 0.8em;
25
- }
1
+ #TitlesIndex > section.titles, #TitlesCreate > section.titles, #Popup.titles {
2
+ h3 {
3
+ text-align: center;
4
+ margin: 1em 0 0 0;
5
+ }
26
6
 
27
- div.fieldset {
28
- @include flex-direction(column);
29
- margin: 0 1em 0 0;
30
- }
7
+ form {
8
+ @include display(flex);
9
+ @include align-items(flex-start);
10
+ width: 100%;
11
+ max-width: 500px;
12
+ margin: 1em auto 0 auto;
13
+ padding: 0 20px;
14
+ }
31
15
 
32
- input {
33
- @include flex(1);
34
- border: 1px solid lighten($gray-blue, 25%);
35
- font-family: inherit;
36
- font-size: inherit;
37
- }
16
+ form div.fieldset {
17
+ @include flex-direction(column);
18
+ @include display(flex);
19
+ width: 100%;
20
+ margin: 0 1em 0 0;
21
+ }
38
22
 
39
- button {
40
- @include transition(box-shadow 0.2s);
41
- @include flex(0 0 auto);
42
- margin: 2px 0 0 0;
43
- text-transform: uppercase;
44
- font-size: 0.8em;
45
- font-weight: bold;
46
- padding: 4px 8px;
47
- border-radius: 2px;
48
- color: lighten($green, 35%);
49
- text-shadow: 0 -1px darken($green, 10%);
50
- text-decoration: none;
51
- background-color: darken($green, 5%);
52
- box-shadow: inset 0 1px 1px 0 lighten($green, 15%);
53
-
54
- &:hover {
55
- box-shadow: inset 0 0 0 0 lighten($green, 15%), 0 1px 1px darken($green, 25%);
56
- }
57
-
58
- &:active {
59
- box-shadow: none;
60
- }
23
+ form ~ p {
24
+ max-width: 500px;
25
+ width: 100%;
26
+ margin: 0.3em 0 3em 0;
27
+ font-size: 0.8em;
28
+ }
61
29
 
62
- }
30
+ form input {
31
+ @include flex(1);
32
+ border: 1px solid $gray-blue;
33
+ font-family: inherit;
34
+ font-size: inherit;
35
+ }
63
36
 
37
+ form button {
38
+ @include transition(box-shadow 0.2s);
39
+ @include flex(0 0 auto);
40
+ margin: 2px 0 0 0;
41
+ text-transform: uppercase;
42
+ font-size: 0.8em;
43
+ font-weight: bold;
44
+ padding: 4px 8px;
45
+ border-radius: 2px;
46
+ color: lighten($green, 35%);
47
+ text-shadow: 0 -1px darken($green, 10%);
48
+ text-decoration: none;
49
+ background-color: darken($green, 5%);
50
+
51
+ &:active {
52
+ box-shadow: inset 0 0 1px 0 darken($green, 25%);
64
53
  }
65
54
  }
66
- }
67
55
 
68
- #TitlesIndex > section > ul.titles, #TitlesCreate > section ul.titles {
69
- width: 100%;
70
- max-width: 500px;
56
+ ul.titles {
57
+ width: 100%;
58
+ max-width: 500px;
59
+ padding: 0 20px;
60
+ margin: 1em auto 0 auto;
61
+ }
71
62
 
72
- h3 {
63
+ ul.titles h3 {
73
64
  @include justify-content(center);
74
65
  }
75
66
 
76
- }
67
+ ul.titles li {
68
+ @include flex-direction(column);
69
+ @include align-items(flex-start);
70
+ padding: 0.5em 0;
71
+
72
+ &:first-child {
73
+ position: relative;
77
74
 
78
- #TitlesIndex > section > ul.titles li, #TitlesCreate > section ul.titles li {
79
- @include flex-direction(column);
80
- @include align-items(flex-start);
81
- padding: 0.5em 0;
82
-
83
- &:first-child {
84
- position: relative;
85
-
86
- &:before {
87
- content: "Current";
88
- position: absolute;
89
- text-transform: uppercase;
90
- right: calc(100% + 1em);
91
- top: 1em;
92
- font-size: 0.7em;
93
- font-weight: normal;
94
- color: lighten($gray-blue, 20%);
75
+ &:before {
76
+ content: "Current";
77
+ position: absolute;
78
+ text-transform: uppercase;
79
+ right: calc(100% + 1em);
80
+ top: 1.1em;
81
+ font-size: 0.7em;
82
+ font-weight: normal;
83
+ color: $gray-blue;
84
+ }
95
85
  }
96
86
  }
97
87
 
98
- p {
88
+ ul.titles li p {
99
89
  margin: 0;
100
90
  }
101
- a {
91
+
92
+ ul.titles li a {
102
93
  font-size: 0.7em;
103
94
  font-weight: lighter;
104
95
  }
105
- }
106
96
 
107
- #TitlesIndex > section div.fieldset.errors, #TitlesCreate > section div.fieldset.errors {
108
- input {
97
+ div.fieldset.errors input {
109
98
  border: 1px solid darken($red, 5%);
110
99
  border-radius: 2px 2px 0 0;
111
100
  }
112
101
 
113
- input + ul.errors {
102
+ div.fieldset.errors input + ul.errors {
114
103
  font-size: 0.8em;
115
104
  margin: 0;
116
105
  padding: 0 1em;
@@ -124,9 +113,10 @@
124
113
 
125
114
  color: darken($red, 50%);
126
115
  text-shadow: 0 1px lighten($red, 5%);
116
+ }
127
117
 
128
- li {
118
+ div.fieldset.errors input + ul.errors li {
129
119
  @include justify-content(center);
130
- }
131
120
  }
132
121
  }
122
+
@@ -1,4 +1,4 @@
1
- div.overlay {
1
+ [as='Overlay'] {
2
2
  @include display(flex);
3
3
  @include justify-content(center);
4
4
  @include align-items(center);
@@ -15,7 +15,7 @@ main.overlayed {
15
15
  position: fixed;
16
16
  }
17
17
 
18
- div.popup {
18
+ [as='Popup'] {
19
19
  @include display(flex);
20
20
  @include flex-direction(column);
21
21
  border-radius: 2px;
@@ -33,7 +33,7 @@ div.popup {
33
33
  }
34
34
  }
35
35
 
36
- div.popup header {
36
+ [as='Popup'] header {
37
37
  @include flex(0 0 auto);
38
38
  @include display(flex);
39
39
  @include align-items(center);
@@ -50,7 +50,7 @@ div.popup header {
50
50
  }
51
51
  }
52
52
 
53
- div.popup.errors {
53
+ [as='Popup'].errors {
54
54
  background: rgb(200, 158, 158);
55
55
 
56
56
  header {
@@ -64,19 +64,3 @@ div.popup.errors {
64
64
  margin: 1em;
65
65
  }
66
66
  }
67
-
68
- #PostsListPopup {
69
- ol {
70
- list-style-type: none;
71
- font-size: 1.2em;
72
- padding: 0;
73
- li {
74
- margin: 1.2em 1em;
75
- padding: 0;
76
- }
77
- }
78
-
79
- div.empty {
80
- text-align: center;
81
- }
82
- }
@@ -12,6 +12,7 @@ code, pre {
12
12
  white-space: pre;
13
13
  word-spacing: normal;
14
14
  font-size: 1em;
15
+ white-space: pre-wrap;
15
16
 
16
17
  -moz-tab-size: 4;
17
18
  -o-tab-size: 4;
@@ -1,14 +1,32 @@
1
1
  module Admin
2
2
  module Posts
3
3
  class TagsController < Admin::ApplicationController
4
+ before_action :post
4
5
 
5
6
  def index
6
- @post = Admin::Post.find(params[:post_id])
7
7
  @tags = Admin::Tag.all
8
+ if params.has_key?(:q) && !params[:q].blank?
9
+ @tags = @tags.search_by_name(params[:q])
10
+ end
11
+ end
12
+
13
+ def create
14
+ @tag = Tag.search_by_name(tag_params[:name]).first
15
+ if @tag.nil?
16
+ @tag = Tag.create(tag_params)
17
+ end
18
+
19
+ if @post.tags.include? @tag
20
+ @post.tags = @post.tags.where.not(id: @tag.id)
21
+ else
22
+ @post.tags << @tag
23
+ end
24
+
25
+ @post.save!
26
+
8
27
  end
9
28
 
10
29
  def toggle
11
- @post = Admin::Post.find(params[:post_id])
12
30
  @tag = Admin::Tag.find(params[:tag_id])
13
31
  if @post.tags.include? @tag
14
32
  @post.tags = @post.tags.where.not(id: @tag.id)
@@ -19,6 +37,16 @@ module Admin
19
37
  @post.save!
20
38
  end
21
39
 
40
+ protected
41
+
42
+ def post
43
+ @post ||= Admin::Post.find(params[:post_id])
44
+ end
45
+
46
+ def tag_params
47
+ params.require(:tag).permit(:name)
48
+ end
49
+
22
50
  end
23
51
  end
24
52
  end
@@ -18,16 +18,21 @@ module Admin
18
18
  redirect_to admin_post_titles_path(@title.post) and return
19
19
  end
20
20
 
21
- render 'index'
21
+ respond_to do |format|
22
+ format.html { render 'index' }
23
+ format.js
24
+ end
22
25
  end
23
26
 
24
27
  def update
28
+ @post = Admin::Post.find(params[:post_id])
25
29
  @title = Admin::Title.find(params[:id])
26
- if @title.update(title_params)
27
- redirect_to admin_post_titles_path(@title.post) and return
28
- end
30
+ @title.update(title_params)
29
31
 
30
- render 'index'
32
+ respond_to do |format|
33
+ format.html { render 'index' }
34
+ format.js
35
+ end
31
36
  end
32
37
 
33
38
  protected
@@ -1,6 +1,7 @@
1
1
  module Admin
2
2
  class PostsController < Admin::ApplicationController
3
3
  before_action :fetch_post, only: [:show, :edit, :update]
4
+ helper_method :search_posts_params
4
5
 
5
6
  def new
6
7
  @post = Admin::Post.new
@@ -9,15 +10,7 @@ module Admin
9
10
  def index
10
11
  posts = Admin::Post
11
12
 
12
- if params.has_key?(:q) && !params[:q].blank?
13
- @titles = Admin::Title.search_by_name(params[:q])
14
- posts = posts.where('id in (?)', @titles.pluck(:post_id).uniq.compact)
15
- end
16
-
17
- if params.has_key?(:tid) && !params[:tid].blank?
18
- posts = posts.where('? = ANY(posts.tags)', params[:tid])
19
- end
20
-
13
+ posts = posts.search search_posts_params
21
14
  @posts = posts.order('posts.created_at').includes(:titles)
22
15
 
23
16
  respond_to do |format|
@@ -75,11 +68,18 @@ module Admin
75
68
 
76
69
  protected
77
70
 
71
+ def search_posts_params
72
+ params.require(:posts).permit(:title, :tag, :status)
73
+ rescue ActionController::ParameterMissing
74
+ {
75
+ status: 'all'
76
+ }
77
+ end
78
+
78
79
  def title_params
79
80
  params.require(:post).permit(:title)
80
81
  end
81
82
 
82
-
83
83
  def post_params
84
84
  params.require(:post).permit(:content, :status, :stylesheet, :javascript, :slug)
85
85
  end
@@ -2,10 +2,14 @@ module Admin
2
2
  module PostsHelper
3
3
 
4
4
  def post_tags(post)
5
- tags = post.tags.map do |tag|
6
- tag.name.capitalize
5
+ if post.tags.any?
6
+ tags = post.tags.map(&:name).join(', ') << '.'
7
+ else
8
+ tags = 'No tag yet.'
7
9
  end
8
- tags.join(', ')
10
+
11
+ tags << ' ' << link_to('Change tags', admin_post_tags_path(post), remote: true)
12
+ content_tag :div, tags.html_safe, class: %w(tags), as: 'Post.Tags'
9
13
  end
10
14
 
11
15
  def edit_content_tag(post)
@@ -97,4 +97,24 @@ module ApplicationHelper
97
97
  content_tag :main, html_options, &block
98
98
  end
99
99
 
100
+ ##
101
+ # Render a popup tag
102
+ #
103
+ def popup_tag(partial = nil, html_options = {}, &block)
104
+ html_options.reverse_merge!({
105
+ as: 'Popup',
106
+ id: 'Popup',
107
+ class: 'popup',
108
+ overlay: true
109
+ })
110
+
111
+ if html_options.delete(:overlay) == true
112
+ content_tag :div, class: %w(overlay), as: 'Overlay' do
113
+ content_tag :div, partial, html_options, &block
114
+ end
115
+ else
116
+ content_tag :div, partial, html_options, &block
117
+ end
118
+ end
119
+
100
120
  end
@@ -41,6 +41,10 @@ module ContentTagHelper
41
41
  @attributes[:class]
42
42
  end
43
43
 
44
+ def [](k)
45
+ @attributes[k]
46
+ end
47
+
44
48
  def []=(k,v)
45
49
  @attributes[k] = v
46
50
  end
@@ -7,6 +7,25 @@ module Admin
7
7
  before_save :compile!, prepend: true
8
8
  before_save :excerptize!
9
9
 
10
+ def self.search(params = {})
11
+ rel = self
12
+
13
+ if params.has_key?(:tag) && !params[:tag].blank?
14
+ rel = rel.where('? = ANY(posts.tags)', params[:tag])
15
+ end
16
+
17
+ if params.has_key?(:title) && !params[:title].blank?
18
+ titles = Admin::Title.search_by_name(params[:title])
19
+ rel = rel.where('id in (?)', titles.pluck(:post_id).uniq.compact)
20
+ end
21
+
22
+ if params.has_key?(:status)
23
+ rel = rel.status(params[:status])
24
+ end
25
+
26
+ rel
27
+ end
28
+
10
29
  def publish!(params = {})
11
30
  self.assign_attributes(params)
12
31
  self.published_at = DateTime.now
@@ -31,6 +50,10 @@ module Admin
31
50
  read_attribute(:content) || ""
32
51
  end
33
52
 
53
+ def status
54
+ published? ? 'published' : 'draft'
55
+ end
56
+
34
57
  private
35
58
 
36
59
  def compile!
@@ -26,7 +26,7 @@ class Post < ActiveRecord::Base
26
26
  scope :status, lambda {|status|
27
27
  if status.eql?("published")
28
28
  where "posts.published_at IS NOT NULL"
29
- else
29
+ elsif status.eql?('drafted')
30
30
  where "posts.published_at IS NULL"
31
31
  end
32
32
  }
@@ -25,9 +25,17 @@ class Tag < ActiveRecord::Base
25
25
  end
26
26
  end
27
27
 
28
+ include PgSearch
28
29
  include ActiveModel::Validations
29
30
  validates_with Tag::Validator
30
31
 
32
+ pg_search_scope :search_by_name,
33
+ against: :name,
34
+ :using => {
35
+ :tsearch => {:prefix => true}
36
+ }
37
+
38
+
31
39
  def ==(other)
32
40
  self.class.table_name == other.class.table_name && self.id == other.id
33
41
  end
@@ -0,0 +1,9 @@
1
+ <li>
2
+ <%= content_tag :h3, link_to(post.title, edit_admin_post_path(post)), class: %w(title) %>
3
+ <%= content_tag :span, class: %w(status) do %>
4
+ <%= content_tag :span, post.status.capitalize, class: %W(status #{post.status}) %>
5
+ <% if post.published? %>
6
+ <%= content_tag :span, time_ago_in_words(post.published_at).capitalize, class: %w(published date) %>
7
+ <% end %>
8
+ <% end %>
9
+ </li>
@@ -1,74 +1,34 @@
1
- <%= content_tag :header, as: "Post.Header", href: admin_post_image_path(@post), method: 'POST' do |header| %>
2
- <nav class='actions'>
3
- <div class='meta'>
4
- <button class='button' as='Editor.Save'>
5
- Save
6
- <template for='Editor.Save'>
7
- <%= content_tag :div, as: 'Editor.Save.Dialog', id: 'SavePost', href: admin_post_path(@post), method: 'PUT' do %>
8
- <div class='progress'></div>
9
- <p class='message'>
10
- Saving...
11
- </p>
12
- <% end %>
13
- </template>
14
- </button>
1
+ <%= content_for :post_buttons do %>
2
+ <%= content_tag :button do |button|%>
15
3
 
16
- <%= link_to 'Edit', edit_admin_post_path(@post), class: %w(selected button) %>
17
- <%= link_to 'Preview', admin_post_path(@post), class: %w(button) %>
18
- <%= link_to 'Tags', admin_post_tags_path(@post), class: %w(button) %>
19
- <%= link_to 'Title', admin_post_titles_path(@post), class: %w(button) %>
20
- </div>
4
+ <% button[:class] << 'button' %>
5
+ <% button[:as] = 'Editor.Save' %>
21
6
 
7
+ Save & Preview
22
8
 
23
- <%= content_tag :div, class: %w(publish state), href: admin_post_toggle_path(@post), method: :put, published: @post.published?, as: 'Post.Publish' do %>
24
- <label>Published</label>
25
- <label>Draft</label>
26
- <% end %>
27
- </nav>
28
- <template for='Post.Header'>
29
- <%= render 'admin/posts/header/dropping', css: %w(status dropping hidden) %>
30
- <%= render 'admin/posts/header/uploading', css: %w(status uploading hidden) %>
31
- <%= render 'admin/posts/header/error', css: %w(status error hidden) %>
32
- </template>
33
-
34
- <% if @post.header? %>
35
- <% header[:style] = "background-image: url(#{@post.header.url});" %>
36
- <% end %>
37
- <div class='drop'>
38
- </div>
39
-
40
- <div class='title'>
9
+ <template for='Editor.Save'>
10
+ <%= content_tag :div do |div| %>
41
11
 
42
- <%= content_tag :svg,
43
- method: 'DELETE',
44
- href: admin_post_image_path(@post),
45
- class: %w(clear),
46
- version: "1.1",
47
- xmlns: "http://www.w3.org/2000/svg",
48
- 'xmlns:xlink' => "http://www.w3.org/1999/xlink",
49
- x: "0px",
50
- y: "0px",
51
- viewBox: "0 0 20 20",
52
- 'enable-background' => "new 0 0 20 20",
53
- 'xml:space' => "preserve" do |svg| %>
12
+ <% div[:as] = 'Editor.Save.Dialog' %>
13
+ <% div[:id] = 'SavePost' %>
14
+ <% div[:href] = admin_post_path(@post) %>
15
+ <% div[:method] = 'PUT' %>
54
16
 
55
- <% if !@post.header? %>
56
- <% svg.css << 'hidden' %>
57
- <% end %>
17
+ <div class='progress'></div>
18
+ <p class='message'>
19
+ Saving...
20
+ </p>
58
21
 
59
- <path d="M16,2H4C2.9,2,2,2.9,2,4v12c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C18,2.9,17.1,2,16,2z M13.061,14.789L10,11.729
60
- l-3.061,3.06l-1.729-1.728L8.271,10L5.211,6.939l1.729-1.729L10,8.271l3.059-3.061l1.729,1.729L11.729,10l3.06,3.061L13.061,14.789z
61
- "/>
62
22
  <% end %>
23
+ </template>
63
24
 
64
- <%= link_to @post.title, admin_post_titles_path(@post), class: %w(title) %>
65
- <input type='file' />
66
- <p class='browse'>Set a header image. Either <strong>drop</strong> an image here or <strong>select an image</strong>.</p>
67
- </div>
68
-
25
+ <% end %>
69
26
  <% end %>
70
27
 
71
- <section>
28
+ <%= render 'admin/posts/header/base', post: @post %>
29
+
30
+ <section id='PostEditContent'>
31
+ <%= post_tags(@post) %>
72
32
 
73
33
  <%= edit_content_tag(@post) do %>
74
34
  <%= h @post.content %>
@@ -0,0 +1,54 @@
1
+ <%= content_tag :header, as: "Post.Header", id: 'PostHeader', href: admin_post_image_path(post), method: 'post' do |header| %>
2
+
3
+ <nav class='actions'>
4
+ <%= content_tag :div, yield(:post_buttons), class: %w(buttons) %>
5
+
6
+ <%= content_tag :div, class: %w(publish state), href: admin_post_toggle_path(@post), method: :put, published: @post.published?, as: 'Post.Publish' do %>
7
+ <label>Published</label>
8
+ <label>Draft</label>
9
+ <% end %>
10
+ </nav>
11
+
12
+ <template for='Post.Header'>
13
+ <%= render 'admin/posts/header/dropping', css: %w(status dropping hidden) %>
14
+ <%= render 'admin/posts/header/uploading', css: %w(status uploading hidden) %>
15
+ <%= render 'admin/posts/header/error', css: %w(status error hidden) %>
16
+ </template>
17
+
18
+ <% if @post.header? %>
19
+ <% header[:style] = "background-image: url(#{@post.header.url});" %>
20
+ <% end %>
21
+ <div class='drop'>
22
+ </div>
23
+
24
+ <div class='title'>
25
+
26
+ <%= content_tag :svg,
27
+ method: 'DELETE',
28
+ href: admin_post_image_path(@post),
29
+ class: %w(clear),
30
+ version: "1.1",
31
+ xmlns: "http://www.w3.org/2000/svg",
32
+ 'xmlns:xlink' => "http://www.w3.org/1999/xlink",
33
+ x: "0px",
34
+ y: "0px",
35
+ viewBox: "0 0 20 20",
36
+ 'enable-background' => "new 0 0 20 20",
37
+ 'xml:space' => "preserve" do |svg| %>
38
+
39
+ <% if !@post.header? %>
40
+ <% svg.css << 'hidden' %>
41
+ <% end %>
42
+
43
+ <path d="M16,2H4C2.9,2,2,2.9,2,4v12c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C18,2.9,17.1,2,16,2z M13.061,14.789L10,11.729
44
+ l-3.061,3.06l-1.729-1.728L8.271,10L5.211,6.939l1.729-1.729L10,8.271l3.059-3.061l1.729,1.729L11.729,10l3.06,3.061L13.061,14.789z
45
+ "/>
46
+ <% end %>
47
+
48
+ <%= link_to @post.title, admin_post_titles_path(@post), class: %w(title), remote: true, as: 'Post.Title' %>
49
+ <input type='file' />
50
+ <p class='browse'>Set a header image. Either <strong>drop</strong> an image here or <strong>select an image</strong>.</p>
51
+ </div>
52
+
53
+ <% end %>
54
+