postablr 0.0.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.
Files changed (82) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +22 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/postablr/application.js +15 -0
  5. data/app/assets/javascripts/postablr/blog.js +2 -0
  6. data/app/assets/javascripts/postablr/entries.js +2 -0
  7. data/app/assets/stylesheets/postablr/application.css +13 -0
  8. data/app/assets/stylesheets/postablr/blog.css +4 -0
  9. data/app/assets/stylesheets/postablr/entries.css +4 -0
  10. data/app/controllers/postablr/application_controller.rb +4 -0
  11. data/app/controllers/postablr/blog_controller.rb +21 -0
  12. data/app/controllers/postablr/entries_controller.rb +43 -0
  13. data/app/helpers/postablr/application_helper.rb +4 -0
  14. data/app/helpers/postablr/blog_helper.rb +27 -0
  15. data/app/helpers/postablr/entries_helper.rb +4 -0
  16. data/app/helpers/postablr/truncate_html_helper.rb +52 -0
  17. data/app/models/postablr/ar_publish.rb +172 -0
  18. data/app/models/postablr/entry.rb +37 -0
  19. data/app/models/postablr/entry/audio.rb +23 -0
  20. data/app/models/postablr/entry/image.rb +17 -0
  21. data/app/models/postablr/entry/link.rb +8 -0
  22. data/app/models/postablr/entry/post.rb +8 -0
  23. data/app/models/postablr/entry/quote.rb +7 -0
  24. data/app/models/postablr/entry/video.rb +29 -0
  25. data/app/uploaders/entry_audio_uploader.rb +55 -0
  26. data/app/uploaders/entry_photo_uploader.rb +42 -0
  27. data/app/views/layouts/postablr/application.html.erb +14 -0
  28. data/app/views/postablr/blog/_entry_display.haml +3 -0
  29. data/app/views/postablr/blog/comments/_comment.haml +10 -0
  30. data/app/views/postablr/blog/comments/_form.haml +6 -0
  31. data/app/views/postablr/blog/comments/create.js.haml +5 -0
  32. data/app/views/postablr/blog/comments/new.html.haml +0 -0
  33. data/app/views/postablr/blog/comments/new.js.haml +2 -0
  34. data/app/views/postablr/blog/entries/show.haml +39 -0
  35. data/app/views/postablr/blog/show.html.haml +46 -0
  36. data/app/views/postablr/blog/show/_aside.haml +19 -0
  37. data/app/views/postablr/blog/show/_audio.haml +13 -0
  38. data/app/views/postablr/blog/show/_image.haml +13 -0
  39. data/app/views/postablr/blog/show/_link.haml +11 -0
  40. data/app/views/postablr/blog/show/_post.haml +14 -0
  41. data/app/views/postablr/blog/show/_quote.haml +12 -0
  42. data/app/views/postablr/blog/show/_video.haml +16 -0
  43. data/app/views/postablr/entries/_entries_menu.haml +14 -0
  44. data/app/views/postablr/entries/_entry.haml +4 -0
  45. data/app/views/postablr/entries/_form.haml +58 -0
  46. data/app/views/postablr/entries/edit.haml +1 -0
  47. data/app/views/postablr/entries/fields/_audio.haml +4 -0
  48. data/app/views/postablr/entries/fields/_image.haml +2 -0
  49. data/app/views/postablr/entries/fields/_link.haml +3 -0
  50. data/app/views/postablr/entries/fields/_post.haml +3 -0
  51. data/app/views/postablr/entries/fields/_quote.haml +3 -0
  52. data/app/views/postablr/entries/fields/_video.haml +2 -0
  53. data/app/views/postablr/entries/index.html.haml +11 -0
  54. data/app/views/postablr/entries/index.js.haml +2 -0
  55. data/app/views/postablr/entries/list/_audio.haml +14 -0
  56. data/app/views/postablr/entries/list/_image.haml +12 -0
  57. data/app/views/postablr/entries/list/_link.haml +11 -0
  58. data/app/views/postablr/entries/list/_post.haml +14 -0
  59. data/app/views/postablr/entries/list/_quote.haml +11 -0
  60. data/app/views/postablr/entries/list/_video.haml +17 -0
  61. data/app/views/postablr/entries/new.html.haml +2 -0
  62. data/app/views/postablr/entries/show.html.haml +5 -0
  63. data/config/routes.rb +20 -0
  64. data/db/migrate/20121222195404_create_postablr_entries.rb +18 -0
  65. data/db/migrate/20121222195417_create_postablr_entry_videos.rb +16 -0
  66. data/db/migrate/20121222200141_create_postablr_entry_quotes.rb +10 -0
  67. data/db/migrate/20121222200237_create_postablr_entry_posts.rb +10 -0
  68. data/db/migrate/20121222200303_create_postablr_entry_links.rb +10 -0
  69. data/db/migrate/20121222200402_create_postablr_entry_images.rb +12 -0
  70. data/db/migrate/20121222200810_create_postablr_entry_audios.rb +12 -0
  71. data/lib/postablr.rb +4 -0
  72. data/lib/postablr/engine.rb +11 -0
  73. data/lib/postablr/version.rb +3 -0
  74. data/lib/tasks/postablr_tasks.rake +4 -0
  75. data/test/factories/postablr_entries.rb +16 -0
  76. data/test/factories/postablr_entry_audios.rb +9 -0
  77. data/test/factories/postablr_entry_images.rb +10 -0
  78. data/test/factories/postablr_entry_links.rb +8 -0
  79. data/test/factories/postablr_entry_posts.rb +9 -0
  80. data/test/factories/postablr_entry_quotes.rb +8 -0
  81. data/test/factories/postablr_entry_videos.rb +14 -0
  82. metadata +358 -0
@@ -0,0 +1,37 @@
1
+ module Postablr
2
+ class Entry < ActiveRecord::Base
3
+ attr_accessible :comments_enabled, :content_source, :highlight,
4
+ :is_published, :postable_id, :postable_type, :publish_at, :slug,
5
+ :unpublish_at, :user_id, :postable_attributes
6
+
7
+ belongs_to :user
8
+ belongs_to :postable, :polymorphic => true , :dependent=>:destroy , :touch => true
9
+
10
+ #has_many :comments, :as=>:commentable , :class_name=>Forum::Comment
11
+
12
+ accepts_nested_attributes_for :postable, :reject_if => :all_blank, :allow_destroy => true
13
+
14
+ after_initialize :defaults
15
+
16
+ acts_as_taggable
17
+
18
+ include Postablr::ArPublish
19
+ publish_control :publish_by_default => false
20
+
21
+ def categories_list
22
+ categories.map(&:name).join(", ")
23
+ end
24
+
25
+ def defaults
26
+ return unless new_record?
27
+ self.comments_enabled = true
28
+ end
29
+
30
+
31
+ def postable_name
32
+ postable.class.table_name.split("_")[2].singularize
33
+ end
34
+
35
+
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ module Postablr
2
+ class Entry::Audio < ActiveRecord::Base
3
+ attr_accessible :file, :file_content_type, :file_size
4
+ has_one :entry, :as => :postable
5
+ mount_uploader :file, EntryAudioUploader
6
+ validates_presence_of :file
7
+ attr_accessor :content_type, :filename, :size
8
+
9
+ #validates_presence_of :title
10
+
11
+ def path=(value)
12
+ logger.info value
13
+ uploaded_file = CarrierWave::SanitizedFile.new :tempfile => value,
14
+ :filename => filename,
15
+ :content_type => content_type
16
+ self.file = uploaded_file
17
+ end
18
+
19
+ def audio_title
20
+ title.blank? ? File.basename( file.url ) : title
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module Postablr
2
+ class Entry::Image < ActiveRecord::Base
3
+ attr_accessible :body, :photo, :photo_content_type, :photo_size
4
+ has_one :entry, :as => :postable
5
+ mount_uploader :photo, EntryPhotoUploader
6
+ validates_presence_of :photo
7
+ attr_accessor :filename
8
+
9
+ def path=(value)
10
+ uploaded_file = CarrierWave::SanitizedFile.new :tempfile => value,
11
+ :filename => filename,
12
+ :content_type => photo_content_type
13
+ self.photo = uploaded_file
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ module Postablr
2
+ class Entry::Link < ActiveRecord::Base
3
+ attr_accessible :title, :url
4
+ has_one :entry, :as => :postable
5
+ validates_presence_of :title
6
+ validates_presence_of :url
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Postablr
2
+ class Entry::Post < ActiveRecord::Base
3
+ attr_accessible :body, :body, :title
4
+ has_one :entry, :as => :postable
5
+ validates_presence_of :title
6
+ validates_presence_of :body
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Postablr
2
+ class Entry::Quote < ActiveRecord::Base
3
+ attr_accessible :body, :source
4
+ has_one :entry, :as => :postable
5
+ validates_presence_of :body
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ module Postablr
2
+ class Entry::Video < ActiveRecord::Base
3
+ attr_accessible :download_url, :duration,
4
+ :embed_url, :flv, :service,
5
+ :thumbnail, :title, :embed_html,
6
+ :url
7
+
8
+ has_one :entry, :as => :postable
9
+ attr_accessor :url
10
+ before_save :check_video
11
+
12
+ def check_video
13
+ v = UnvlogIt.new(self.url)
14
+ self.title = v.title
15
+ self.thumbnail = v.thumbnail
16
+ self.embed_url = v.embed_url
17
+ self.duration = v.duration
18
+ self.download_url = v.download_url
19
+ self.embed_html = v.embed_html("100%", "600")
20
+ self.flv = v.flv
21
+ end
22
+
23
+ def embed(width, height, options={})
24
+ embed_html(width=425, height=344, options={})
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ class EntryAudioUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
+
9
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
10
+ # include Sprockets::Helpers::RailsHelper
11
+ # include Sprockets::Helpers::IsolatedHelper
12
+
13
+ # Choose what kind of storage to use for this uploader:
14
+ storage :file
15
+ # storage :fog
16
+
17
+ # Override the directory where uploaded files will be stored.
18
+ # This is a sensible default for uploaders that are meant to be mounted:
19
+ def store_dir
20
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
21
+ end
22
+
23
+ # Provide a default URL as a default if there hasn't been a file uploaded:
24
+ # def default_url
25
+ # # For Rails 3.1+ asset pipeline compatibility:
26
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
27
+ #
28
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
29
+ # end
30
+
31
+ # Process files as they are uploaded:
32
+ # process :scale => [200, 300]
33
+ #
34
+ # def scale(width, height)
35
+ # # do something
36
+ # end
37
+
38
+ # Create different versions of your uploaded files:
39
+ # version :thumb do
40
+ # process :scale => [50, 50]
41
+ # end
42
+
43
+ # Add a white list of extensions which are allowed to be uploaded.
44
+ # For images you might use something like this:
45
+ def extension_white_list
46
+ %w(mp3)
47
+ end
48
+
49
+ # Override the filename of the uploaded files:
50
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
51
+ # def filename
52
+ # "something.jpg" if original_filename
53
+ # end
54
+
55
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ class EntryPhotoUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
+
9
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
10
+ # include Sprockets::Helpers::RailsHelper
11
+ # include Sprockets::Helpers::IsolatedHelper
12
+
13
+ # Choose what kind of storage to use for this uploader:
14
+ storage :file
15
+ # storage :fog
16
+
17
+ # Override the directory where uploaded files will be stored.
18
+ # This is a sensible default for uploaders that are meant to be mounted:
19
+ def store_dir
20
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
21
+ end
22
+
23
+ # Create different versions of your uploaded files:
24
+ version :square do
25
+ process :resize_to_fill => [50, 50]
26
+ end
27
+
28
+ version :thumb_large do
29
+ process :resize_to_fill => [216, 144]
30
+ end
31
+
32
+ version :large do
33
+ process :resize_to_fit => [620, 360]
34
+ end
35
+
36
+ # Add a white list of extensions which are allowed to be uploaded.
37
+ # For images you might use something like this:
38
+ def extension_white_list
39
+ %w(jpg jpeg gif png)
40
+ end
41
+
42
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Postablr</title>
5
+ <%= stylesheet_link_tag "postablr/application", :media => "all" %>
6
+ <%= javascript_include_tag "postablr/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ - cache "ExploreEntries/#{entry.id}-#{entry.updated_at}" do
2
+ = render "postablr/entries/list/#{entry.postable_name}", :postable => entry.postable unless entry.postable.blank?
3
+
@@ -0,0 +1,10 @@
1
+ - cache("CommentPartial-#{comment.id}") do
2
+ %li{:id=>"entry-comment-#{comment.id}"}
3
+ = image_tag comment.user.profile.avatar.url(:thumb)
4
+ .comment_data
5
+ %h5
6
+ = comment.user.name
7
+ %span.metadata
8
+ = l( comment.created_at, :format=>:short)
9
+ .comment
10
+ = comment.body
@@ -0,0 +1,6 @@
1
+ %h2 Participa
2
+ = semantic_form_for @comment, :url=>blog_entry_comments_path(@entry), :remote=>true do |f|
3
+ = f.inputs do
4
+ = f.input :body
5
+ = f.actions do
6
+ = f.submit
@@ -0,0 +1,5 @@
1
+
2
+ $("#entry_comments").append('#{ escape_javascript(render( :partial=>"blog/comments/comment", :locals=>{:comment=>@comment })) }');
3
+ $('#forum_comment_body').val('');
4
+ $('#comments_count').html("#{@comment.commentable.comments.size}");
5
+
@@ -0,0 +1,2 @@
1
+
2
+ $("#comment_form").html( "#{escape_javascript( render( "blog/comments/form") )}" )
@@ -0,0 +1,39 @@
1
+ %section.publications
2
+ - unless @entry.postable.blank?
3
+ -#= link_to "Edit", edit_entry_path(@entry)
4
+ -#= link_to "Delete", entry_path(@entry), :method=>:delete, :confirm=>"Are you sure?"
5
+
6
+ = render "blog/show/#{@entry.postable.class.to_s.underscore.split('/')[1]}", :postable => @entry.postable
7
+
8
+ .tags
9
+ Tags:
10
+ = raw @entry.tags.collect{|o| link_to o.name, blog_tag_path(o.name)}.join(", ")
11
+
12
+ .col_system.col.fluid.comments_system
13
+ .col.medium
14
+ %h2
15
+ Comentarios
16
+ %span#comments_count= @entry.comments.size
17
+
18
+ %ul#entry_comments
19
+ = render :partial=>'blog/comments/comment', :collection=>@entry.comments , :as=>:comment
20
+ #comment_form
21
+ - if @entry.comments_enabled?
22
+ = render 'blog/comments/form'
23
+ - else
24
+ = t("comments_disabled")
25
+ .col.small.help
26
+ %h4
27
+ Ayuda
28
+ .help.guideline
29
+ %p
30
+ Este es un espacio para la sana convivencia, por favor respeta los lineamientos de la comunidad al momento de participar.
31
+ %p
32
+ Puedes utilizar algo de HTML para enriquecer tus comentarios
33
+ %aside
34
+
35
+ - unless @relateds
36
+ .hentry_related
37
+ %h2 Related
38
+ - @relateds.each do |entry|
39
+ = link_to entry.postable.title , blog_entry_path( entry ), :class=>"pjax"
@@ -0,0 +1,46 @@
1
+ .page_header
2
+ %h1 Publicaciones
3
+ %p
4
+ Blog
5
+ %span.icons.mini &#x25BB;
6
+
7
+ %div.col_system.col.fluid
8
+ %div.col.medium
9
+
10
+ %section.publications
11
+ %ul#masonry_reload.publication_stream.wide
12
+ = render :partial=> 'postablr/blog/entry_display', :collection=> @entries, :as=> :entry
13
+
14
+ %nav.pagination.publication_paginator
15
+ = paginate @entries #, :remote => true
16
+
17
+ %div.col.small.help
18
+ %h4
19
+ %span.icons.mini.circle.magenta &#xE100;
20
+ Most used Tags
21
+ %ul.topics
22
+ - cache("BlogPopularTags", :expires_in=>1.hour) do
23
+ - Postablr::Entry.tag_counts_on(:tags).limit(16).each do |tag|
24
+ %li
25
+ %span.icons.small &#xE100;
26
+ = link_to("#{tag.name} (#{tag.count})", blog_tag_path(tag.name), :class=>"pjax")
27
+
28
+ %h4
29
+ %span.icons.mini.circle.magenta &#xE9A0;
30
+ Filter publications
31
+ %ul
32
+ %li
33
+ Published types
34
+ %ul
35
+ %li
36
+ = link_to "Texto", filter_blog_path("post")
37
+ %li
38
+ = link_to "Imagen", filter_blog_path("image")
39
+ %li
40
+ = link_to "Cita", filter_blog_path("quote")
41
+ %li
42
+ = link_to "Libro", filter_blog_path("ebook")
43
+ %li
44
+ = link_to "Audio", filter_blog_path("audio")
45
+ %li
46
+ = link_to "Video", filter_blog_path("video")
@@ -0,0 +1,19 @@
1
+ %div.col.small.help
2
+ %aside
3
+ %h4
4
+ Sobre el autor
5
+ .hentry_metadata
6
+ -#= image_tag( postable.entry.user.profile.avatar.url(:thumb), :style=>"width:50px" )
7
+ %h5
8
+ -#= postable.entry.user.name
9
+ .bio
10
+ -#= postable.entry.user.profile.bio
11
+ %h4
12
+ Comparte esto
13
+ .addthis_toolbox.addthis_default_style
14
+ %a.addthis_button_facebook_like{"fb:like:layout" => "button_count"}
15
+ %a.addthis_button_tweet
16
+ %a.addthis_counter.addthis_pill_style
17
+ %script{:src => "http://s7.addthis.com/js/250/addthis_widget.js#pubid=panchoavila", :type => "text/javascript"}
18
+
19
+
@@ -0,0 +1,13 @@
1
+ %li.article.video
2
+ .article_video
3
+ = raw postable.body
4
+ .article_meta
5
+ %span.meta.kind Audio
6
+ %ul.playlist
7
+ %li
8
+ %a{ :href=>"#{postable.file.url}"}= postable.audio_title
9
+ %span.meta.author
10
+ = postable.entry.user.name
11
+
12
+ = render :partial=>'postablr/blog/show/aside', :locals=>{:postable=>postable}
13
+
@@ -0,0 +1,13 @@
1
+ %li.article.photo
2
+ = image_tag postable.photo.url(:large)
3
+ .article_meta
4
+ %span.meta.kind Imagen
5
+ %h3
6
+ = raw clean_html( postable.body )
7
+ %span.meta.author
8
+ Por
9
+ = postable.entry.user.name
10
+
11
+ .article_text
12
+ %p= raw sanitize_relaxed(postable.body)
13
+ = render :partial=>'postablr/blog/show/aside', :locals=>{:postable=>postable}
@@ -0,0 +1,11 @@
1
+ %li.article.link
2
+ .article_meta
3
+ %span.meta.kind Enlace
4
+ %h3
5
+ %a{:href => "#{postable.url}"}="#{postable.title} →"
6
+ %span.meta.author
7
+ Por
8
+ = postable.entry.user.name
9
+
10
+ = render :partial=>'postablr/blog/show/aside', :locals=>{:postable=>postable}
11
+
@@ -0,0 +1,14 @@
1
+ %div.col_system.col.fluid
2
+ %div.col.medium
3
+ %article.hentry
4
+ %h2.entry-title
5
+ = postable.title
6
+ %p.byline.author.vcard
7
+ %span.meta.kind Post
8
+ By
9
+ %span.fn
10
+ = postable.entry.user.name
11
+ .entry-content
12
+ = raw sanitize_relaxed( postable.body )
13
+
14
+ = render :partial=>'postablr/blog/show/aside', :locals=>{:postable=>postable}