th_simple_blog 0.0.1 → 0.0.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjE4ZDM5YzgwOTQ2NGE2NDE2ZWQ1MjllMzQ4MzU2MDEzNmVmZGViMw==
4
+ ZmRkYWYzMTM1OGM4NDQyNTNkZjJkZTE3MGMwMDEwZjAzYjkxYzM1Yg==
5
5
  data.tar.gz: !binary |-
6
- MDE1ODRkYzYzYzQ2NDdhOTU1ZDY4ZmY2MmZmMTE4OTNlOTU2NTFkYQ==
6
+ M2U5NWJmMTc2ZjBkNjE4M2E0MjIwNmYyMjAzNTY2NjZiNDVlNGU2Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGUxNjYxMDVlM2Q4ZDhkMGIyYmRkMTIzY2VkZmM5ODljYjA5YTg1MmY3NmFh
10
- ZDQ2NmQ0ZmVjYjY2NzE0NTYwYmVlMTRmMTgyMmNmYmU0M2EwMzJlYzNhZGNl
11
- NDhhNzUxNTk1MmNmMmFhZmJiMDBlMjA5M2EwMTU0NWFmMGUyMDg=
9
+ ODUzNjQyZDk3NWVlMTI4NTM5Njc3ZmI2YjEzZTZiYjA4NDdkZGEwZmMwZTE2
10
+ OTg3ZDgyMzA3ZWMxYzliMDg5MDBjNmU3M2YyZmQwOTFkOWJhZGRjM2NiODUz
11
+ NDZlNzRhNTYzYzFhODg5Y2RlYzU5ZTc4YjliZDU1ODZmYzUxYTU=
12
12
  data.tar.gz: !binary |-
13
- NzBjNTY5NjFmMWM2MmM0OWUwNTgyNjFiZGJkMDMyYWFjZTg4NDBmYWMxNGFk
14
- ZGZkNzdjM2U2OTg0ZmMwZmY0ZWEwYTc5NmRiZDk5ZGYyMjRiMjg2ZmYxMjEz
15
- NDlmODgzZmY1YWM4MzYyY2M2ZWRiOWE4ZGU3NWVhYzRlNDVjYzA=
13
+ NjAwZjVkNDhlYjcyZTZhMzcxYWIxM2Q1MWVmNTZkYTk4NDdkMzg4Yjg5YjAy
14
+ ZDk0OGM2MDkxNjU1OTM2MDZlYTA5ZGJkNDAyNGE3NjFiNjZmNjgyZDc1YTEz
15
+ ZmVjOGQzODM1NjZlYzMwODU3YTNlNDVkNTY3MzRmMjhkNzcyNDk=
@@ -0,0 +1,8 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //
4
+ //= require bootstrap
5
+ //= require bootstrap-lightbox
6
+ //
7
+ //= require ./simple_posts
8
+ //= require_self
@@ -0,0 +1,15 @@
1
+ $(function() {
2
+ if(!$("#simple_blog_simple_posts_edit, #simple_blog_simple_posts_new").length)
3
+ return;
4
+
5
+ $("#simple_blog_simple_post_tags_list").each(function() {
6
+ $(this).tagsManager({
7
+ prefilled: $(this).val().split(/,/g),
8
+ preventSubmitOnEnter: true,
9
+ typeahead: true,
10
+ typeaheadSource: $(this).data("tags"),
11
+ hiddenTagListName: $(this).prop("name")
12
+ });
13
+ $(this).prop("name", "").val("");
14
+ });
15
+ })
@@ -0,0 +1,2 @@
1
+ @import "simple_posts";
2
+ @import "bootstrap-lightbox";
@@ -0,0 +1,5 @@
1
+ #simple_blog_simple_posts_show {
2
+ .thumbnail {
3
+ margin: 0 20px 20px 0;
4
+ }
5
+ }
@@ -2,8 +2,8 @@ class SimpleBlog::SimplePostsController < InheritedResources::Base
2
2
  defaults :resource_class => SimpleBlog::SimplePost
3
3
  include SimpleAdminPanel::ControllerExtensions
4
4
  alias_method_chain :collection, :search_and_pagination
5
+ before_filter :ensure_defaults, only: :new
5
6
  before_filter :ensure_user, only: [:new, :create]
6
- before_filter :ensure_published_at, only: [:new]
7
7
 
8
8
  protected
9
9
  def end_of_association_chain
@@ -12,10 +12,15 @@ class SimpleBlog::SimplePostsController < InheritedResources::Base
12
12
 
13
13
  private
14
14
  def ensure_user
15
- build_resource.user ||= current_user
15
+ build_resource.tap do |post|
16
+ post.user ||= current_user
17
+ end
16
18
  end
17
19
 
18
- def ensure_published_at
19
- build_resource.published_at ||= (Time.current + 1.hour).beginning_of_hour
20
+ def ensure_defaults
21
+ build_resource.tap do |post|
22
+ post.author_name ||= current_user.name
23
+ post.published_at ||= (Time.current + 1.hour).beginning_of_hour
24
+ end
20
25
  end
21
26
  end
@@ -1,10 +1,32 @@
1
1
  class SimpleBlog::SimplePost < ActiveRecord::Base
2
+ include SimpleContentManagement::ContentText
3
+
4
+ mount_uploader :thumbnail, SimpleBlog::SimplePostThumbnailUploader
5
+
2
6
  belongs_to :user
7
+ has_and_belongs_to_many :tags, class_name: "SimpleBlog::SimplePostTag"
3
8
 
4
9
  scope :active, where(deleted: false)
5
- scope :published, ->{ where("published_at IS NOT NULL AND published_at < ?", DateTime.current) }
10
+ scope :published, ->{ where("published_at IS NOT NULL AND published_at < ? AND (expires_at IS NULL OR expires_at > ?)", DateTime.current, DateTime.current) }
11
+
12
+ attr_accessible :title, :content_html, :published_at, :expires_at, :tags_list, :author_name, :thumbnail, :thumbnail_cache
13
+
14
+ def to_param
15
+ "#{id}-#{title.parameterize}"
16
+ end
17
+
18
+ def tags_list
19
+ tags.pluck("name").join ","
20
+ end
6
21
 
7
- attr_accessible :title, :content_html, :published_at
22
+ def tags_list= tags_list
23
+ tag_names = tags_list.split %r{\s*,\s*}
24
+ existing_tags = SimpleBlog::SimplePostTag.where(name: tag_names).all
25
+ existing_tag_names = existing_tags.map &:name
26
+ self.tags = (existing_tags + tag_names.map{ |tag_name|
27
+ SimpleBlog::SimplePostTag.create(name: tag_name) unless existing_tag_names.include? tag_name
28
+ }.compact)
29
+ end
8
30
 
9
31
  def destroy
10
32
  update_attribute :deleted, true
@@ -0,0 +1,11 @@
1
+ class SimpleBlog::SimplePostTag < ActiveRecord::Base
2
+ attr_accessible :name
3
+
4
+ has_and_belongs_to_many :posts, class_name: "SimpleBlog::SimplePost"
5
+
6
+ validates_presence_of :name
7
+
8
+ def to_param
9
+ "#{id}-#{name.parameterize}"
10
+ end
11
+ end
@@ -1,11 +1,26 @@
1
1
  <%= simple_form_for [:admin, @simple_post], url: @simple_post.new_record? ? simple_blog_simple_posts_path : simple_blog_simple_post_path(@simple_post) do |f| %>
2
2
  <%= f.input :title, input_html: { class: "input-xlarge" } %>
3
+ <%= f.input :tags_list, input_html: { data: { tags: SimpleBlog::SimplePostTag.pluck("name") } } %>
4
+ <%= f.input :author_name %>
5
+
6
+ <%= f.input :thumbnail do %>
7
+ <%= image_tag(@simple_post.thumbnail_url :thumb) if @simple_post.thumbnail? %>
8
+ <%= f.input_field :thumbnail %>
9
+ <%= f.hidden_field :thumbnail_cache %>
10
+ <% end %>
11
+
3
12
  <%= f.input :content_html, input_html: { cols: 120, rows: 7, class: "input-xxlarge redactor" } %>
13
+
4
14
  <%= f.input :published_at, wrapper: :append, hint: "Laat leeg om de post niet te publiceren." do %>
5
15
  <%= f.input_field :published_at, as: :string, value: (resource.published_at ? l(resource.published_at, format: "%Y-%m-%d %H:%M") : ""), placeholder: "YYYY-MM-DD HH:MM", class: "input-medium" %>
6
16
  <span class="add-on"><%= l(resource.published_at.presence || Time.current, format: "%Z") %></span>
7
17
  <% end %>
8
18
 
19
+ <%= f.input :expires_at, wrapper: :append, hint: "Laat leeg om de post niet automatisch te verwijderen." do %>
20
+ <%= f.input_field :expires_at, as: :string, value: (resource.expires_at ? l(resource.expires_at, format: "%Y-%m-%d %H:%M") : ""), placeholder: "YYYY-MM-DD HH:MM", class: "input-medium" %>
21
+ <span class="add-on"><%= l(resource.published_at.presence || Time.current, format: "%Z") %></span>
22
+ <% end %>
23
+
9
24
  <div class="form-actions">
10
25
  <%= f.button :submit %>
11
26
  </div>
@@ -1,8 +1,10 @@
1
1
  <%= table_list_for @simple_posts, sortable: false, resource_class: SimpleBlog::SimplePost do |t| %>
2
2
  <%= t.item :title, as: :link %>
3
3
  <%= t.item :user, :name %>
4
+ <%= t.item :author_name %>
4
5
  <%= t.item :created_at, as: :short_datetime %>
5
6
  <%= t.item :published_at, as: :short_datetime %>
7
+ <%= t.item :expires_at, as: :short_datetime %>
6
8
  <%= t.item :updated_at, as: :short_datetime %>
7
9
  <%= t.item as: :actions %>
8
10
  <% end %>
@@ -1 +1,13 @@
1
+ <% @simple_post.tags.each do |tag| %>
2
+ <%= content_tag :span, tag.name, class: "label" %>
3
+ <% end %>
4
+
5
+ <div id="simple-post-thumbnail-lightbox" class="lightbox hide fade" tabindex="-1" role="dialog" aria-hidden="true">
6
+ <%= link_to image_tag("simple_blog/button_lightbox_close.png"), "#simple-post-thumbnail-lightbox", class: "close", data: { toggle: "lightbox" } %>
7
+ <div class="lightbox-content">
8
+ <%= image_tag @simple_post.thumbnail_url(:content) %>
9
+ </div>
10
+ </div>
11
+
12
+ <%= link_to image_tag(@simple_post.thumbnail_url(:thumb), class: "thumbnail pull-left"), "#simple-post-thumbnail-lightbox", data: { toggle: "lightbox" } if @simple_post.thumbnail? %>
1
13
  <%= @simple_post.content_html.html_safe %>
@@ -10,7 +10,11 @@ nl:
10
10
  title: Titel
11
11
  published_at: Publicatiedatum
12
12
  published_at_abbr: Publicatie
13
+ expires_at: Verloopdatum
14
+ expires_atr_abbr: Verloopt
13
15
  created_at: Aangemaakt
14
16
  updated_at: Laatst gewijzigd
15
17
  updated_at_abbr: Gewijzigd
16
- user_name: Gebruiker
18
+ user_name: Gebruiker
19
+ tags_list: Tags
20
+ author_name: Auteur
@@ -0,0 +1,25 @@
1
+ class SimpleBlog::SimplePostThumbnailUploader < CarrierWave::Uploader::Base
2
+ include CarrierWave::MiniMagick
3
+ storage :file
4
+
5
+ # Override the directory where uploaded files will be stored.
6
+ # This is a sensible default for uploaders that are meant to be mounted:
7
+ def store_dir
8
+ "system/blog/post_thumbnails/#{model.id}"
9
+ end
10
+
11
+ # Create different versions of your uploaded files:
12
+ version :thumb do
13
+ process :resize_to_fill => [160, 160]
14
+ end
15
+
16
+ version :content do
17
+ process :resize_to_limit => [800, 800]
18
+ end
19
+
20
+ # Add a white list of extensions which are allowed to be uploaded.
21
+ # For images you might use something like this:
22
+ def extension_white_list
23
+ %w(png gif jpg jpeg)
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleBlog
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/simple_blog.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "simple_blog/engine"
2
+ require "simple_blog/simple_post_thumbnail_uploader"
2
3
 
3
4
  module SimpleBlog
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: th_simple_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - toby hinloopen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-19 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -25,13 +25,13 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.12
27
27
  - !ruby/object:Gem::Dependency
28
- name: activerecord-jdbcsqlite3-adapter
28
+ name: th_simple_content_management
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -45,11 +45,15 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - app/assets/javascripts/simple_blog/application.js
49
- - app/assets/stylesheets/simple_blog/application.css
48
+ - app/assets/images/simple_blog/button_lightbox_close.png
49
+ - app/assets/javascripts/simple_blog/index.js
50
+ - app/assets/javascripts/simple_blog/simple_posts.js
51
+ - app/assets/stylesheets/simple_blog/index.css.scss
52
+ - app/assets/stylesheets/simple_blog/simple_posts.css.scss
50
53
  - app/controllers/simple_blog/simple_posts_controller.rb
51
54
  - app/helpers/simple_blog/application_helper.rb
52
55
  - app/models/simple_blog/simple_post.rb
56
+ - app/models/simple_blog/simple_post_tag.rb
53
57
  - app/views/simple_blog/simple_posts/_form.html.erb
54
58
  - app/views/simple_blog/simple_posts/edit.html.erb
55
59
  - app/views/simple_blog/simple_posts/index.html.erb
@@ -58,6 +62,7 @@ files:
58
62
  - config/locales/simple_blog/nl/models/simple_post.yml
59
63
  - config/routes.rb
60
64
  - lib/simple_blog/engine.rb
65
+ - lib/simple_blog/simple_post_thumbnail_uploader.rb
61
66
  - lib/simple_blog/version.rb
62
67
  - lib/simple_blog.rb
63
68
  - lib/tasks/simple_blog_tasks.rake
@@ -1,15 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */