fuel 0.3.34 → 0.4.1

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.
@@ -35,7 +35,6 @@ $page-offset: 0 25px 50px 275px;
35
35
  text-transform: uppercase;
36
36
  }
37
37
 
38
-
39
38
  // Form Area
40
39
  .page-area {
41
40
  @include rem(margin, $page-offset);
@@ -2,4 +2,5 @@
2
2
  // ========================================
3
3
 
4
4
  @import "layout";
5
- @import "typography";
5
+ @import "typography";
6
+ @import "syntax";
@@ -0,0 +1,15 @@
1
+ <%= Rouge::Themes::Github.render(scope: '.highlight') %>
2
+
3
+ .highlight {
4
+ background-color: white;
5
+ border: thin solid $grey-base;
6
+ padding: 10px 20px;
7
+ overflow-x: auto;
8
+ word-break: inherit;
9
+ word-wrap: inherit;
10
+ letter-spacing: 0.2px;
11
+
12
+ span {
13
+ line-height: 25px;
14
+ }
15
+ }
@@ -42,4 +42,16 @@ $editor-button-transition: all 0.2s ease-in-out;
42
42
  cursor: pointer;
43
43
  color: $blue-base;
44
44
  }
45
+ }
46
+
47
+
48
+ .preview-link-area {
49
+ @include row();
50
+ @include rem(margin-top, 10px);
51
+ }
52
+
53
+ .preview--link {
54
+ @extend .link-primary;
55
+ @include font-type($primary-sans-serif, normal, 700);
56
+ @include rem(margin-top, 15px);
45
57
  }
@@ -62,7 +62,7 @@ input[type="submit"] {
62
62
  // Specific Teaser Heights
63
63
  textarea {
64
64
  &.tease { @include rem(height, 60px); }
65
- &.post { @include rem(height, 250px); }
65
+ &.post { @include rem(height, 350px); }
66
66
  }
67
67
 
68
68
  select{
@@ -50,8 +50,11 @@ module Fuel
50
50
 
51
51
  def preview
52
52
  @content = params[:fuel_post][:content]
53
+ content = Fuel::Post.new.to_html(@content)
54
+ html = render_to_string partial: "fuel/admin/posts/content", locals: { content: content }
55
+
53
56
  respond_to do |format|
54
- format.js
57
+ format.json { render json: { html: html } }
55
58
  end
56
59
  end
57
60
 
@@ -62,7 +65,7 @@ module Fuel
62
65
  private
63
66
 
64
67
  def post_params
65
- params.require(:fuel_post).permit(:tag, :author_id, :content, :title, :teaser, :featured_image, :published, :published_at)
68
+ params.require(:fuel_post).permit(:tag, :author_id, :content, :title, :teaser, :featured_image, :published, :published_at, :format)
66
69
  end
67
70
 
68
71
  def update_published_at
@@ -36,5 +36,9 @@ module Fuel
36
36
  )
37
37
  end
38
38
 
39
+ def format_options
40
+ Fuel::Post::Formats::DISPLAY.dup.invert
41
+ end
42
+
39
43
  end
40
44
  end
@@ -8,7 +8,7 @@ module Fuel
8
8
  belongs_to :author
9
9
 
10
10
  if Rails.version[0].to_i < 4
11
- attr_accessible :tag, :author_id, :content, :title, :teaser, :featured_image, :seo_title, :seo_description, :published_at
11
+ attr_accessible :tag, :author_id, :content, :title, :teaser, :featured_image, :seo_title, :seo_description, :published_at, :format
12
12
  end
13
13
 
14
14
  if Fuel.configuration.aws_bucket
@@ -25,6 +25,13 @@ module Fuel
25
25
  scope :published, -> { where(published: true) }
26
26
  scope :recent, -> { order("published_at DESC").order("created_at DESC") }
27
27
 
28
+ module Formats
29
+ MARKDOWN = "markdown"
30
+ HTML = "html"
31
+ DISPLAY = { HTML => "HTML", MARKDOWN => "Markdown" }
32
+ DEFAULT = HTML
33
+ end
34
+
28
35
  def s3_credentials
29
36
  {:bucket => Fuel.configuration.aws_bucket, :access_key_id => Fuel.configuration.aws_access_key, :secret_access_key => Fuel.configuration.aws_secret_access_key}
30
37
  end
@@ -57,11 +64,27 @@ module Fuel
57
64
  teaser.present? ? teaser : content
58
65
  end
59
66
 
60
- def to_html
61
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
62
- :autolink => true, :space_after_headers => true)
67
+ def to_html(content = raw_content)
68
+ markdown = Redcarpet::Markdown.new(Fuel::Html,
69
+ :autolink => true, :space_after_headers => true, fenced_code_blocks: true, disable_indented_code_blocks: true)
63
70
  raw markdown.render(content)
64
71
  end
65
72
 
73
+ def content
74
+ markdown? ? to_html(raw_content) : raw_content
75
+ end
76
+
77
+ def raw_content
78
+ attributes["content"]
79
+ end
80
+
81
+ def html?
82
+ format == Formats::HTML
83
+ end
84
+
85
+ def markdown?
86
+ format == Formats::MARKDOWN
87
+ end
88
+
66
89
  end
67
90
  end
@@ -2,14 +2,14 @@
2
2
  $(function() {
3
3
  $body = $("body");
4
4
 
5
- var editorId = "fuel_post_content";
5
+ var editorId = "fuel_post_content_html";
6
6
  var editorStylesheetPath = "<%= stylesheet_path('fuel/wysihtml') %>";
7
7
  var editorSubmitUrl = '<%= s3_direct_post.url %>';
8
8
  var editorFormData = JSON.parse('<%= s3_direct_post.fields.to_json.html_safe %>');
9
9
  var editorHostUrl = '//<%= @s3_direct_post.url.host %>/';
10
10
 
11
11
  if ($("body").hasClass("posts-controller")){
12
- var editor = new wysihtml5.Editor(editorId, { // id of textarea element
12
+ wysihtml5Editor = new wysihtml5.Editor(editorId, { // id of textarea element
13
13
  toolbar: "editor", // id of toolbar element
14
14
  parserRules: wysihtml5ParserRules,
15
15
  stylesheets: editorStylesheetPath
@@ -67,6 +67,8 @@
67
67
  });
68
68
  });
69
69
  <% end %>
70
+
71
+ setCorrectEditor();
70
72
  };
71
73
 
72
74
  });
@@ -36,6 +36,12 @@
36
36
  <%= f.label :teaser, 'Post Tease' %>
37
37
  <%= f.text_area :teaser, class: 'tease' %>
38
38
  </fieldset>
39
+ <fieldset>
40
+ <div class="form-group-half">
41
+ <%= f.label :format %>
42
+ <%= f.select :format, options_for_select(format_options, selected: f.object.format) %>
43
+ </div>
44
+ </fieldset>
39
45
  </div>
40
46
  <div class="form-container--right card">
41
47
  <%= f.label :featured_image, 'Featured Image' %>
@@ -45,7 +51,7 @@
45
51
  <%= f.file_field :featured_image %>
46
52
  </div>
47
53
  <div class="form-container--full">
48
- <fieldset>
54
+ <fieldset class="editor-area" data-format="html">
49
55
  <%= f.label :content, 'Your Post' %>
50
56
  <ul id="editor" style="display: none;">
51
57
  <li class="editor-button" data-wysihtml5-command="bold" title="CTRL+B"><i class="fa fa-bold"></i></li>
@@ -96,7 +102,14 @@
96
102
  </fieldset>
97
103
  </div>
98
104
  </ul>
99
- <%= f.text_area :content, class: 'post' %>
105
+ <%= f.text_area :content, class: 'post', id: "fuel_post_content_html" %>
106
+ </fieldset>
107
+ <fieldset class="editor-area" data-format="markdown">
108
+ <%= f.label :content, 'Your Post' %>
109
+ <%= f.text_area :content, value: f.object.raw_content, class: 'post', id: "fuel_post_content_markdown" %>
110
+ <div class="preview-link-area">
111
+ <%= link_to 'Preview Post', '#', class: "trigger-preview preview--link", data: { url: fuel.admin_posts_preview_path } %>
112
+ </div>
100
113
  </fieldset>
101
114
  <fieldset>
102
115
  <%= f.submit (action_name == "edit" ? "Update Post" : "Create Post"), class: 'button button--secondary' %>
@@ -105,4 +118,5 @@
105
118
  <% end %>
106
119
  </fieldset>
107
120
  </div>
108
- <% end %>
121
+ <% end %>
122
+ <%= render partial: 'post_preview' %>
@@ -2,10 +2,9 @@
2
2
  <section class="page">
3
3
  <header class="page-header">
4
4
  <h5 class="page-header--title"><span>Post</span>: <%= @post.title %></h5>
5
- <%= link_to 'Preview Post', '#', class: "js-menu-trigger page-header--link" %>
5
+ <%= link_to 'View Post', post_path(@post), class: "page-header--link", target: "_blank" %>
6
6
  </header>
7
7
  <div class="page-area">
8
8
  <%= render 'form' %>
9
- <%= render partial: 'post_preview' %>
10
9
  </div>
11
10
  </section>
data/config/routes.rb CHANGED
@@ -6,7 +6,7 @@ Fuel::Engine.routes.draw do
6
6
  # admin namespace is listed first intentionally
7
7
  namespace :admin do
8
8
  root to: 'posts#index'
9
- get "posts/preview" => 'posts#preview'
9
+ post "posts/preview" => 'posts#preview'
10
10
  get "posts/:slug/posts/preview" => 'posts#preview'
11
11
  resources :posts do
12
12
  member do
@@ -0,0 +1,5 @@
1
+ class AddFormatToFuelPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :format, :string, default: "html"
4
+ end
5
+ end
data/lib/fuel.rb CHANGED
@@ -14,6 +14,10 @@ require "pickadate-rails"
14
14
  require "aws-sdk"
15
15
  require "jquery-fileupload-rails"
16
16
  require "fuel/aws"
17
+ require "github/markup"
18
+ require "rouge"
19
+ require "rouge/plugins/redcarpet"
20
+ require "fuel/html"
17
21
 
18
22
  module Fuel
19
23
 
data/lib/fuel/html.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Fuel::Html < Redcarpet::Render::HTML
2
+ include Rouge::Plugins::Redcarpet # yep, that's it.
3
+ end
data/lib/fuel/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fuel
2
- VERSION = "0.3.34"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -28,7 +28,7 @@ namespace :fuel do
28
28
  desc "Markdown to HTML"
29
29
  task :markdown_to_html => :environment do
30
30
  Fuel::Post.all.each do |post|
31
- post.content = post.to_html
31
+ post.content = post.content
32
32
  post.save
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.34
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Francis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -192,6 +192,34 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: github-markup
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rouge
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: sqlite3
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -425,7 +453,9 @@ files:
425
453
  - app/assets/javascripts/fuel/facebook.js
426
454
  - app/assets/javascripts/fuel/pickadate-datepicker.js
427
455
  - app/assets/javascripts/fuel/posts.js.erb
456
+ - app/assets/javascripts/fuel/showdown.js
428
457
  - app/assets/javascripts/fuel/sliding-panel.js
458
+ - app/assets/javascripts/fuel/to-markdown.js
429
459
  - app/assets/javascripts/fuel/wysihtml5x-toolbar.min.js
430
460
  - app/assets/stylesheets/fuel/_page-layout.scss
431
461
  - app/assets/stylesheets/fuel/_post-editor.scss
@@ -433,6 +463,7 @@ files:
433
463
  - app/assets/stylesheets/fuel/application.css.scss
434
464
  - app/assets/stylesheets/fuel/base/_base.scss
435
465
  - app/assets/stylesheets/fuel/base/_layout.scss
466
+ - app/assets/stylesheets/fuel/base/_syntax.scss.erb
436
467
  - app/assets/stylesheets/fuel/base/_typography.scss
437
468
  - app/assets/stylesheets/fuel/components/_alerts.scss
438
469
  - app/assets/stylesheets/fuel/components/_animations.scss
@@ -502,6 +533,7 @@ files:
502
533
  - db/migrate/20150604155028_add_published_at_to_fuel_posts.rb
503
534
  - db/migrate/20150604161900_remove_posted_at_from_fuel_posts.rb
504
535
  - db/migrate/20150608221309_add_start_date_to_authors.rb
536
+ - db/migrate/20151014140731_add_format_to_fuel_posts.rb
505
537
  - lib/blog_importer.rb
506
538
  - lib/example_author.rb
507
539
  - lib/fuel.rb
@@ -509,6 +541,7 @@ files:
509
541
  - lib/fuel/aws.rb
510
542
  - lib/fuel/configuration.rb
511
543
  - lib/fuel/engine.rb
544
+ - lib/fuel/html.rb
512
545
  - lib/fuel/version.rb
513
546
  - lib/generators/fuel/install_generator.rb
514
547
  - lib/generators/fuel/views_generator.rb
@@ -598,7 +631,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
598
631
  version: '0'
599
632
  requirements: []
600
633
  rubyforge_project:
601
- rubygems_version: 2.2.2
634
+ rubygems_version: 2.4.8
602
635
  signing_key:
603
636
  specification_version: 4
604
637
  summary: Fuel is a dead simple blogging gem (mountable engine)