fuel 0.3.3 → 0.3.20

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/app/assets/images/fuel/icon-test.png +0 -0
  4. data/app/assets/images/fuel/icons/application-icons.svg +1 -0
  5. data/app/assets/images/fuel/icons/calendar-icon.svg +1 -0
  6. data/app/assets/images/fuel/icons/dropdown-arrow-icon.svg +10 -0
  7. data/app/assets/images/fuel/icons/navigation-icons.svg +1 -0
  8. data/app/assets/javascripts/fuel/admin.js.erb +17 -17
  9. data/app/assets/javascripts/fuel/application.js +8 -0
  10. data/app/assets/javascripts/fuel/datepicker.js +11 -0
  11. data/app/assets/javascripts/fuel/facebook.js +12 -0
  12. data/app/assets/javascripts/fuel/posts.js.erb +16 -0
  13. data/app/assets/javascripts/fuel/rich-text.js +9 -0
  14. data/app/assets/javascripts/fuel/sliding-panel.js +11 -0
  15. data/app/assets/stylesheets/fuel/_page-layout.scss +61 -0
  16. data/app/assets/stylesheets/fuel/_post-list.scss +70 -0
  17. data/app/assets/stylesheets/fuel/application.css.scss +27 -2
  18. data/app/assets/stylesheets/fuel/base/_base.scss +5 -0
  19. data/app/assets/stylesheets/fuel/base/_layout.scss +54 -0
  20. data/app/assets/stylesheets/fuel/base/_typography.scss +102 -0
  21. data/app/assets/stylesheets/fuel/components/_alerts.scss +27 -0
  22. data/app/assets/stylesheets/fuel/components/_animations.scss +26 -0
  23. data/app/assets/stylesheets/fuel/components/_application-icons.scss +42 -0
  24. data/app/assets/stylesheets/fuel/components/_buttons.scss +106 -0
  25. data/app/assets/stylesheets/fuel/components/_card.scss +39 -0
  26. data/app/assets/stylesheets/fuel/components/_components.scss +13 -0
  27. data/app/assets/stylesheets/fuel/components/_forms.scss +90 -0
  28. data/app/assets/stylesheets/fuel/components/_navbar.scss +45 -0
  29. data/app/assets/stylesheets/fuel/components/_navigation-icons.scss +41 -0
  30. data/app/assets/stylesheets/fuel/components/_page-sidebar.scss +60 -0
  31. data/app/assets/stylesheets/fuel/components/_sliding-panel.scss +59 -0
  32. data/app/assets/stylesheets/fuel/settings/_reset.scss +46 -0
  33. data/app/assets/stylesheets/fuel/settings/_settings.scss +19 -0
  34. data/app/assets/stylesheets/fuel/settings/mixins/_layout.scss +20 -0
  35. data/app/assets/stylesheets/fuel/settings/mixins/_misc.scss +27 -0
  36. data/app/assets/stylesheets/fuel/settings/mixins/_rem.scss +46 -0
  37. data/app/assets/stylesheets/fuel/settings/mixins/_typography.scss +64 -0
  38. data/app/assets/stylesheets/fuel/settings/variables/_alerts.scss +9 -0
  39. data/app/assets/stylesheets/fuel/settings/variables/_buttons.scss +8 -0
  40. data/app/assets/stylesheets/fuel/settings/variables/_colors.scss +55 -0
  41. data/app/assets/stylesheets/fuel/settings/variables/_typography.scss +25 -0
  42. data/app/controllers/fuel/admin/admin_controller.rb +7 -0
  43. data/app/controllers/fuel/admin/authors_controller.rb +80 -0
  44. data/app/controllers/fuel/admin/posts_controller.rb +68 -54
  45. data/app/controllers/fuel/fuel_controller.rb +5 -0
  46. data/app/controllers/fuel/posts_controller.rb +13 -7
  47. data/app/controllers/fuel_controller.rb +5 -0
  48. data/app/helpers/fuel/posts_helper.rb +28 -1
  49. data/app/models/fuel.rb +5 -0
  50. data/app/models/fuel/author.rb +18 -0
  51. data/app/models/fuel/post.rb +32 -2
  52. data/app/views/fuel/admin/authors/_authors.html.erb +24 -0
  53. data/app/views/fuel/admin/authors/_form.html.erb +52 -0
  54. data/app/views/fuel/admin/authors/edit.html.erb +9 -0
  55. data/app/views/fuel/admin/authors/index.html.erb +7 -0
  56. data/app/views/fuel/admin/authors/new.html.erb +6 -0
  57. data/app/views/fuel/admin/posts/_content.html.erb +5 -0
  58. data/app/views/fuel/admin/posts/_form.html.erb +56 -0
  59. data/app/views/fuel/admin/posts/_post_preview.html.erb +12 -0
  60. data/app/views/fuel/admin/posts/_posts.html.erb +23 -0
  61. data/app/views/fuel/admin/posts/edit.html.erb +11 -0
  62. data/app/views/fuel/admin/posts/index.html.erb +6 -0
  63. data/app/views/fuel/admin/posts/new.html.erb +9 -0
  64. data/app/views/fuel/components/_navbar.html.erb +22 -0
  65. data/app/views/fuel/posts/_additional_info.html.erb +7 -0
  66. data/app/views/fuel/posts/_facebook_sdk.html.erb +17 -0
  67. data/app/views/fuel/posts/_tweet.html.erb +1 -1
  68. data/app/views/fuel/posts/index.html.erb +27 -6
  69. data/app/views/fuel/posts/show.html.erb +19 -2
  70. data/app/views/layouts/fuel/application.html.erb +19 -12
  71. data/config/routes.rb +18 -10
  72. data/db/migrate/20141114201953_add_featured_image_field.rb +5 -0
  73. data/db/migrate/20141118162158_add_teaser_to_posts.rb +5 -0
  74. data/db/migrate/20141217174229_add_featured_image_to_posts.rb +10 -0
  75. data/db/migrate/20150414220732_add_seo_fields_to_post.rb +6 -0
  76. data/db/migrate/20150529201715_add_posted_at_to_posts.rb +5 -0
  77. data/db/migrate/20150529202105_create_fuel_authors.rb +13 -0
  78. data/db/migrate/20150530180444_add_author_id_to_posts.rb +5 -0
  79. data/db/migrate/20150603205232_add_contact_methods_to_authors.rb +8 -0
  80. data/db/migrate/20150604155028_add_published_at_to_fuel_posts.rb +5 -0
  81. data/db/migrate/20150604161900_remove_posted_at_from_fuel_posts.rb +5 -0
  82. data/lib/blog_importer.rb +82 -0
  83. data/lib/example_author.rb +108 -0
  84. data/lib/fuel.rb +7 -1
  85. data/lib/fuel/configuration.rb +16 -1
  86. data/lib/fuel/engine.rb +13 -1
  87. data/lib/fuel/version.rb +1 -1
  88. data/lib/generators/fuel/install_generator.rb +4 -0
  89. data/lib/generators/fuel/views_generator.rb +1 -1
  90. data/lib/generators/templates/fuel.rb +22 -0
  91. data/lib/kaminari/helpers/tag.rb +16 -0
  92. data/lib/tasks/fuel_tasks.rake +35 -4
  93. data/test/fixtures/fuel/authors.yml +11 -0
  94. data/test/models/fuel/author_test.rb +7 -0
  95. metadata +191 -15
  96. data/app/assets/stylesheets/fuel/admin.css.sass +0 -91
  97. data/app/assets/stylesheets/fuel/posts.css.sass +0 -23
  98. data/app/controllers/fuel/application_controller.rb +0 -4
  99. data/app/helpers/fuel/application_helper.rb +0 -34
  100. data/app/views/fuel/admin/posts/_content.html.slim +0 -3
  101. data/app/views/fuel/admin/posts/_form.html.slim +0 -28
  102. data/app/views/fuel/admin/posts/edit.html.slim +0 -4
  103. data/app/views/fuel/admin/posts/index.html.slim +0 -18
  104. data/app/views/fuel/admin/posts/new.html.slim +0 -4
  105. data/app/views/fuel/posts/_post.html.erb +0 -19
@@ -0,0 +1,12 @@
1
+ <%#= form_tag('preview', method: "post", id: "preview_form") do %>
2
+ <%#= hidden_field_tag :content %>
3
+ <%# end %>
4
+ <div class="js-menu sliding-panel-content">
5
+ <header class="sliding-panel-header">
6
+ <h5 class="inverse title">You are currently previewing this post.</h5>
7
+ </header>
8
+ <div class="sliding-panel-body">
9
+ <%= render 'content', content: @post.content %>
10
+ </div>
11
+ </div>
12
+ <div class="js-menu-screen sliding-panel-fade-screen"></div>
@@ -0,0 +1,23 @@
1
+ <aside class="page-sidebar post-sidebar">
2
+ <header class="page-sidebar--header">
3
+ <div class="header-container--left">
4
+ <h5 class="header--title">Your Posts</h5>
5
+ </div>
6
+ <div class="header-container--right">
7
+ <ul class="header-container--right__actions">
8
+ <li><%= link_to 'New Blog Post', fuel.new_admin_post_path, class: 'add-icon' %></li>
9
+ </ul>
10
+ </div>
11
+ </header>
12
+ <ul class="resource-list post-list">
13
+ <% @posts.each do |post| %>
14
+ <%= link_to fuel.edit_admin_post_path(post) do %>
15
+ <li class="resource-item post-item <%= 'active' if @post && @post == post %>">
16
+ <p class="post-item--date"><time><%= post.published ? "Published: #{post.published_at.strftime('%m/%d/%Y')}" : 'Draft' %></time> </p>
17
+ <h5 class="post-item--title"><%= post.title %></h5>
18
+ <p class="post-item--content"><%= truncate_html(post.teaser, length: 60).html_safe %></p>
19
+ </li>
20
+ <% end %>
21
+ <% end %>
22
+ </ul>
23
+ </aside>
@@ -0,0 +1,11 @@
1
+ <%= render 'posts' %>
2
+ <section class="page">
3
+ <header class="page-header">
4
+ <h5 class="page-header--title"><span>Post</span>: <%= @post.title %></h5>
5
+ <%= link_to 'Preview Post', '#', class: "js-menu-trigger page-header--link" %>
6
+ </header>
7
+ <div class="page-area">
8
+ <%= render 'form' %>
9
+ <%= render partial: 'post_preview' %>
10
+ </div>
11
+ </section>
@@ -0,0 +1,6 @@
1
+ <%= render 'posts' %>
2
+ <section class="page-area">
3
+ <div class="no-content-container">
4
+ <p class="no-content-message">Select a post from the list on the left or <%= link_to 'create', new_admin_post_path, class: 'link-primary' %> a new post.</p>
5
+ </div>
6
+ </section>
@@ -0,0 +1,9 @@
1
+ <%= render 'posts' %>
2
+ <section class="page">
3
+ <header class="page-header">
4
+ <h5 class="page-header--title">Create Blog Post</h5>
5
+ </header>
6
+ <div class="page-area">
7
+ <%= render "form" %>
8
+ </div>
9
+ </section>
@@ -0,0 +1,22 @@
1
+ <aside class="navbar" role="navigation" aria-label="">
2
+ <div class="navbar-logo">
3
+ <%= image_tag 'fuel/icon-test.png', alt: 'Fuel' %>
4
+ </div>
5
+ <nav class="navbar-navigation">
6
+ <ul>
7
+ <%= link_to fuel.admin_posts_path do %>
8
+ <li class="navbar-link">
9
+ <i class="posts-icon"></i> Posts
10
+ </li>
11
+ <% end %>
12
+ <%= link_to fuel.admin_authors_path do %>
13
+ <li class="navbar-link">
14
+ <i class="authors-icon"></i> Authors
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ </nav>
19
+ <footer>
20
+
21
+ </footer>
22
+ </aside>
@@ -0,0 +1,7 @@
1
+ <div class="fuel-post-additional-info">
2
+ <!-- <span class="fuel_post_date"><%= post.created_at.strftime('%b %d, %Y') %> - </span> -->
3
+ <span class="fuel-post-author">By <%= post.author.full_name %></span>
4
+ <span class="fuel-social-buttons">
5
+ <%= render 'tweet', post: post if action_name == "show" && Fuel.configuration.twitter %>
6
+ </span>
7
+ </div>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ window.fbAsyncInit = function() {
3
+ FB.init({
4
+ appId : '<%= Fuel.configuration.facebook_app_id %>',
5
+ xfbml : true,
6
+ version : 'v2.2'
7
+ });
8
+ };
9
+
10
+ (function(d, s, id){
11
+ var js, fjs = d.getElementsByTagName(s)[0];
12
+ if (d.getElementById(id)) {return;}
13
+ js = d.createElement(s); js.id = id;
14
+ js.src = "//connect.facebook.net/en_US/sdk.js";
15
+ fjs.parentNode.insertBefore(js, fjs);
16
+ }(document, 'script', 'facebook-jssdk'));
17
+ </script>
@@ -1,4 +1,4 @@
1
1
  <div>
2
- <a href="https://twitter.com/share" class="twitter-share-button" data-text="<%= post.title %>" data-counturl="<%= post_url(post) %>" data-url="<%= post_url(post) %>" data-lang="en">Tweet</a>
2
+ <a href="https://twitter.com/share" class="twitter-share-button" data-text="<%= post.title %>" data-counturl="<%= fuel.post_url(post) %>" data-url="<%= fuel.post_url(post) %>" data-lang="en">Tweet</a>
3
3
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
4
4
  </div>
@@ -1,6 +1,13 @@
1
+ <% content_for :social_meta_tags do %>
2
+ <meta property="og:title" content="<%= @blog_title %>"/>
3
+ <meta property="og:url" content="<%= fuel.blog_root_url %>"/>
4
+ <meta property="og:site_name" content="<%= Fuel.configuration.site_name %>"/>
5
+ <meta property="og:type" content="Website"/>
6
+ <% end %>
7
+
1
8
  <div class="fuel fuel-posts">
2
9
  <div class="tagline">
3
- <h1 class="tagline"><%= link_to @blog_title, blog_root_path %></h1>
10
+ <h1 class="tagline"><%= link_to @blog_title, fuel.blog_root_path %></h1>
4
11
  </div>
5
12
 
6
13
  <% if @posts %>
@@ -8,12 +15,26 @@
8
15
  <%= paginate @posts %>
9
16
  <% @posts.each do |post| %>
10
17
  <article class="fuel-post fuel-post-index">
11
- <h2 class="fuel-post-title"><%= link_to post.title, post %></h2>
12
- <%= render "fuel/posts/post", post: post %>
18
+ <h2 class="fuel-post-title"><%= link_to post.title, fuel.post_path(post) %></h2>
19
+ <div class="fuel-post-additional-info">
20
+ <span class="fuel_post_date"><%= post.created_at.strftime('%b %d, %Y') %> - </span>
21
+ <span class="fuel-post-author">By <%= post.author.full_name %></span>
22
+ </div>
23
+ <% if post.featured_image_file_name.present? || post.featured_image_url.present? %>
24
+ <div class="image-area">
25
+ <%= image_tag post.prioritized_featured_image_url(:medium) %>
26
+ </div>
27
+ <% end %>
28
+ <div class="fuel-post-content">
29
+ <% content = post.teaser && post.teaser.length > 0 ? post.teaser : post.content %>
30
+ <%= truncate_html(content, length: 250).html_safe %>
31
+ </div>
32
+ <% if post.content.length > 800 %>
33
+ <p><%= link_to 'Read more', fuel.post_url(post) %></p>
34
+ <% end %>
13
35
  </article>
14
36
  <% end %>
15
37
  </section>
16
- <% else %>
17
-
18
38
  <% end %>
19
- </div>
39
+
40
+ </div>
@@ -1,10 +1,27 @@
1
+ <% content_for :social_meta_tags do %>
2
+ <meta property="og:image" content="<%= @post.prioritized_featured_image_url %>"/>
3
+ <meta property="og:title" content="<%= @post.title %>"/>
4
+ <meta property="og:url" content="<%= fuel.post_url(@post) %>"/>
5
+ <meta property="og:site_name" content="<%= Fuel.configuration.site_name %>"/>
6
+ <meta property="og:type" content="Website"/>
7
+ <% end %>
8
+
1
9
  <div class="fuel fuel-posts">
2
10
  <div class="tagline">
3
- <h1 class="tagline"><%= link_to @blog_title, blog_root_path %></h1>
11
+ <h1 class="tagline"><%= link_to @blog_title, fuel.blog_root_path %></h1>
4
12
  </div>
5
13
  <article class="fuel-post fuel-post-show">
6
14
  <h2 class="fuel-post-title"><%= @post.title %></h2>
7
- <%= render 'post', post: @post %>
15
+ <div class="fuel-post-additional-info">
16
+ <span class="fuel_post_date"><%= @post.created_at.strftime('%b %d, %Y') %> - </span>
17
+ <span class="fuel-post-author">By <%= @post.author.full_name %></span>
18
+ <span class="fuel-social-buttons">
19
+ <%= render 'tweet', post: @post if Fuel.configuration.twitter %>
20
+ </span>
21
+ </div>
22
+ <div class="fuel-post-content">
23
+ <%= @post.content.html_safe %>
24
+ </div>
8
25
  </article>
9
26
  <div class="disqus-area">
10
27
  <%= render 'disqus' if @disqus_name %>
@@ -1,14 +1,21 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Fuel</title>
5
- <%= stylesheet_link_tag "fuel/application", media: "all" %>
6
- <%= javascript_include_tag "fuel/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
3
+ <head>
4
+ <title><%= @title %></title>
5
+ <meta name="description" content="<%= @description %>">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
+ <%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css", :media => "all" %>
8
+ <%= csrf_meta_tags %>
9
+ <%= stylesheet_link_tag "fuel/application", media: "all" %>
10
+ <script src="//use.typekit.net/nti1hfq.js"></script>
11
+ <script async>try{Typekit.load();}catch(e){}</script>
12
+ </head>
13
+ <body class="<%= controller_name %>-controller <%= action_name %>-action">
14
+ <%= render partial: 'fuel/components/navbar' %>
15
+ <main role="main" aria-label="main-content" class="<%= controller_name -%> <%= action_name -%> navbar-offset">
16
+ <%= yield %>
17
+ </main>
18
+ <%= javascript_include_tag "fuel/application" %>
19
+ <%= javascript_include_tag 'application' %>
20
+ </body>
21
+ </html>
data/config/routes.rb CHANGED
@@ -1,17 +1,25 @@
1
1
  Fuel::Engine.routes.draw do
2
- resources :posts
3
2
 
4
- get "/" => "posts#index", as: :blog_root
3
+ scope module: 'fuel' do
5
4
 
6
- namespace :admin do
7
- root to: 'posts#index'
8
- get "posts/preview" => 'posts#preview'
9
- get "posts/:slug/preview" => 'posts#preview'
10
- resources :posts do
11
- member do
12
- get 'content'
5
+ root to: 'posts#index', as: :blog_root
6
+ # admin namespace is listed first intentionally
7
+ namespace :admin do
8
+ root to: 'posts#index'
9
+ get "posts/preview" => 'posts#preview'
10
+ get "posts/:slug/posts/preview" => 'posts#preview'
11
+ resources :posts do
12
+ member do
13
+ get 'content'
14
+ end
13
15
  end
16
+ resources :authors
14
17
  end
18
+
19
+ get '/posts'=> 'posts#index'
20
+ resources :posts, path: ''
21
+ get '/posts/:id' => 'posts#redirect'
22
+
15
23
  end
16
24
 
17
- end
25
+ end
@@ -0,0 +1,5 @@
1
+ class AddFeaturedImageField < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :featured_image_url, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddTeaserToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :teaser, :text
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class AddFeaturedImageToPosts < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ add_attachment :fuel_posts, :featured_image
5
+ end
6
+
7
+ def self.down
8
+ remove_attachment :fuel_posts, :featured_image
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class AddSeoFieldsToPost < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :seo_title, :string
4
+ add_column :fuel_posts, :seo_description, :text
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddPostedAtToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :posted_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class CreateFuelAuthors < ActiveRecord::Migration
2
+ def change
3
+ create_table :fuel_authors do |t|
4
+ t.string :first_name
5
+ t.string :last_name
6
+ t.string :title
7
+ t.text :bio
8
+ t.attachment :avatar
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class AddAuthorIdToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :author_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ class AddContactMethodsToAuthors < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_authors, :email, :string
4
+ add_column :fuel_authors, :twitter, :string
5
+ add_column :fuel_authors, :github, :string
6
+ add_column :fuel_authors, :dribbble, :string
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ class AddPublishedAtToFuelPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :fuel_posts, :published_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemovePostedAtFromFuelPosts < ActiveRecord::Migration
2
+ def change
3
+ remove_column :fuel_posts, :posted_at
4
+ end
5
+ end
@@ -0,0 +1,82 @@
1
+ require 'open-uri'
2
+ require 'example_author'
3
+
4
+ class BlogImporter
5
+
6
+ DEFAULT_API_ADDRESS = "http://launchpadlab.com/api/posts.json"
7
+
8
+ attr_reader :api_url
9
+ attr_accessor :parsed_json
10
+
11
+ def initialize(args = {})
12
+ @api_url = args.fetch(:api_url, DEFAULT_API_ADDRESS)
13
+ end
14
+
15
+ def pull
16
+ create_authors
17
+ open(api_url) do |f|
18
+ json_string = f.read
19
+ @parsed_json = JSON.parse(json_string)
20
+ end
21
+ add_posts_to_db
22
+ end
23
+
24
+ def add_posts_to_db
25
+ parsed_json.each do |post|
26
+ puts "Importing #{post['title']}"
27
+ post.delete("id")
28
+ author_name = post["author"].dup
29
+ image_url = post["prioritized_featured_image_url"].present? ? post["prioritized_featured_image_url"].dup : nil
30
+ post.delete("prioritized_featured_image_url")
31
+ member = author_name_to_member[author_name]
32
+ author = Fuel::Author.find_by_email(member[:email])
33
+ post["author_id"] = author.id
34
+ post.delete("author")
35
+ new_post = Fuel::Post.new(post)
36
+ new_post.featured_image = URI.parse(image_url) if image_url.present?
37
+ new_post.published_at = post["created_at"] if new_post.published
38
+ puts new_post.published_at
39
+ new_post.save
40
+ end
41
+ end
42
+
43
+ def author_name_to_member
44
+ @key_to_member ||= {
45
+ "BH" => ExampleAuthor::BRENDAN,
46
+ "Brendan" => ExampleAuthor::BRENDAN,
47
+ "Tom" => ExampleAuthor::TOM,
48
+ "TC" => ExampleAuthor::TOM,
49
+ "Ryan" => ExampleAuthor::RYAN,
50
+ "Scott" => ExampleAuthor::SCOTT,
51
+ "Kurt" => ExampleAuthor::KURT,
52
+ "Katie" => ExampleAuthor::KATIE,
53
+ "Scott " => ExampleAuthor::SCOTT,
54
+ "Monique" => ExampleAuthor::MONIQUE,
55
+ "Jack " => ExampleAuthor::JACK,
56
+ "Dave" => ExampleAuthor::DAVE
57
+ }
58
+ end
59
+
60
+ def create_authors
61
+ [ExampleAuthor::BRENDAN, ExampleAuthor::TOM, ExampleAuthor::RYAN, ExampleAuthor::SCOTT, ExampleAuthor::KURT, ExampleAuthor::DAVE, ExampleAuthor::KATIE, ExampleAuthor::MONIQUE, ExampleAuthor::JACK].each do |member_const|
62
+ member = member_const.dup
63
+ author = Fuel::Author.find_by_email(member["email"])
64
+ next if author.present?
65
+ image_path = member[:image_path].dup
66
+ member.delete(:image_path)
67
+ member.delete(:image_alt)
68
+ new_author = Fuel::Author.new(member)
69
+
70
+ avatar_location = "#{Rails.root}/app/assets/images/#{image_path}"
71
+ puts avatar_location
72
+ file = File.open(avatar_location)
73
+ new_author.avatar = file
74
+ file.close
75
+
76
+ puts "creating new author..."
77
+ new_author.save!
78
+ puts "Author #{Fuel::Author.count} created."
79
+ end
80
+ end
81
+
82
+ end