publinator 0.0.34 → 0.0.35

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.
@@ -21,6 +21,16 @@ function moveObject(selector, from, to) {
21
21
  $(selector).find($(from)).remove();
22
22
  }
23
23
 
24
+ function loadPreview() {
25
+ preview_text = $($('textarea')[0]).val();
26
+ $.ajax({
27
+ url: "preview",
28
+ data: {preview_text: preview_text}
29
+ }).done(function( msg ) {
30
+ $('#preview').html( msg );
31
+ });
32
+ }
33
+
24
34
  $(function() {
25
35
  $(".sortable_list").sortable({
26
36
  update: function(){
@@ -33,8 +43,36 @@ $(function() {
33
43
  })
34
44
  }
35
45
  });
46
+
36
47
  $(".sortable_list").disableSelection();
37
48
 
49
+ $("#tabs").tabs();
50
+
51
+ $("fieldset.actions button").button({ icons: { primary: "ui-icon-check" }});
52
+ $("#publishable_type_button").button();
53
+ $(".new_button").button({ icons: { primary: "ui-icon-document" }});
54
+
55
+
56
+
57
+
58
+ $(document).on("keypress keydown", function(event) {
59
+ console.log(event);
60
+ if (event.ctrlKey || event.metaKey) {
61
+ if (event.keyCode == 83) {
62
+ event.preventDefault();
63
+ event.stopPropagation();
64
+ $('form').submit();
65
+ return false;
66
+ }
67
+ else if (event.keyCode == 16) {
68
+ event.preventDefault();
69
+ event.stopPropagation();
70
+ loadPreview();
71
+ return false;
72
+
73
+ }
74
+ }
75
+ });
38
76
 
39
77
  $(".toggle_details").on("click", function(event) {
40
78
  event.preventDefault();
@@ -15,7 +15,7 @@
15
15
 
16
16
  body {
17
17
  font-family: "helvetica neue", helvetica, verdana, arial, helvetica, "sans-serif";
18
- font-size: 1em;
18
+ font-size: 0.9em;
19
19
  background-color: #ccc;
20
20
  margin: 0;
21
21
  padding: 0;
@@ -35,6 +35,10 @@ body {
35
35
  margin: 0;
36
36
  padding: 2em;
37
37
 
38
+ .ui-icon {
39
+ display: inline-block;
40
+ }
41
+
38
42
  table {
39
43
  th {
40
44
  text-align: left;
@@ -50,10 +54,25 @@ body {
50
54
  list-style-type: none;
51
55
 
52
56
  li {
53
- width: 400px;
57
+ width: 600px;
54
58
  border: 1px solid silver;
55
59
  margin: 6px;
56
60
  padding: 8px;
61
+
62
+ .details {
63
+ font-size: 0.7em;
64
+ margin: 12px 0px 0px;
65
+
66
+ span.publication_date {
67
+ float: right;
68
+ }
69
+
70
+ }
71
+
72
+ .controls {
73
+ clear: both;
74
+ float: right;
75
+ }
57
76
  }
58
77
  }
59
78
 
@@ -96,8 +115,15 @@ body {
96
115
  font-weight: bold;
97
116
  }
98
117
  li.action {
99
- display: inline;
100
- padding-right: 2em;
118
+ span.ui-button-text button {
119
+ border: 0px;
120
+ background-color: inherit;
121
+ }
122
+ float: right;
123
+ }
124
+
125
+ li.action.link_action {
126
+ float: left;
101
127
  }
102
128
  li.string {
103
129
  input[type="text"] {
@@ -115,5 +141,9 @@ body {
115
141
  }
116
142
  }
117
143
  }
144
+
145
+ fieldset.advanced_settings {
146
+ display: none;
147
+ }
118
148
  }
119
149
  }
@@ -49,6 +49,10 @@ module Publinator
49
49
  end
50
50
  end
51
51
 
52
+ def preview
53
+ render :text => RDiscount.new(params[:preview_text]).to_html.html_safe, :layout => false
54
+ end
55
+
52
56
  def edit
53
57
  @field_names = @page.editable_fields.collect{ |an| an.to_sym }
54
58
  @page.asset_items.build
@@ -1,4 +1,5 @@
1
1
  require_dependency "publinator/application_controller"
2
+ require 'rdiscount'
2
3
 
3
4
  module Publinator
4
5
  class Manage::PublishableController < ApplicationController
@@ -22,6 +23,10 @@ module Publinator
22
23
  end
23
24
  end
24
25
 
26
+ def preview
27
+ render :text => RDiscount.new(params[:preview_text]).to_html.html_safe, :layout => false
28
+ end
29
+
25
30
  def new
26
31
  @publishable = @publishable_class.new(
27
32
  :publication => Publinator::Publication.new(
@@ -10,4 +10,5 @@ class Publinator::ManageController < Publinator::ApplicationController
10
10
  @publishable_types = Publinator::PublishableType.all
11
11
  render "publinator/manage/index"
12
12
  end
13
+
13
14
  end
@@ -6,5 +6,6 @@
6
6
 
7
7
  has_attached_file :asset
8
8
  default_scope order('updated_at desc')
9
+
9
10
  end
10
11
  #end
@@ -1,12 +1,12 @@
1
1
  <h2>Content Manager Home Page</h2>
2
2
 
3
- <%= link_to "Sections", "/manage/sections" %><br>
4
- <%= link_to "Pages", manage_pages_path %><br>
5
-
3
+ <ul>
4
+ <li><%= link_to "Sections", "/manage/sections" %></li>
5
+ <li><%= link_to "Pages", manage_pages_path %></li>
6
6
  <% @publishable_types.each do |pt| %>
7
- <%= link_to pt.name.pluralize, send("manage_#{pt.name.tableize}_path") %><br>
7
+ <li><%= link_to pt.name.singularize.tableize.titleize, send("manage_#{pt.name.tableize}_path") %></li>
8
8
  <% end %>
9
-
9
+ </ul>
10
10
  <h3>Site Settings</h3>
11
11
 
12
12
  <%= link_to "Publishable Types", "/manage/publishable_types" %><br>
@@ -4,45 +4,63 @@
4
4
  <%= e %><br>
5
5
  <% end %>
6
6
  <% end %>
7
- <%= form.inputs "Page" do %>
8
- <% @field_names.each do |field| %>
9
- <% if field == 'section_id' %>
10
- <%= form.input field, :as => :select, :collection => current_site.sections %>
11
- <% else %>
12
- <%= form.input field %>
7
+
8
+ <div id="tabs">
9
+ <ul>
10
+ <li><a href="#tabs-1">Page</a></li>
11
+ <li><a href="#tabs-2">Assets</a></li>
12
+ <li><a href="#tabs-3">Publication</a></li>
13
+ </ul>
14
+ <div id="tabs-1">
15
+ <%= form.inputs "Page" do %>
16
+ <div id="preview"></div>
17
+ <% @field_names.each do |field| %>
18
+ <% if field == 'section_id' %>
19
+ <%= form.input field, :as => :select, :collection => current_site.sections %>
20
+ <% else %>
21
+ <%= form.input field %>
22
+ <% end %>
23
+ <% end %>
13
24
  <% end %>
25
+ </div>
26
+
27
+ <% if @page.asset_types.length > 0 %>
28
+ <div id="tabs-2">
29
+ <h3>Assets</h3>
30
+ <%= form.semantic_fields_for :asset_items do |asset_form| %>
31
+ <%= asset_form.inputs "Asset" do %>
32
+ <% if asset_form.object.asset.present? %>
33
+ <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
34
+ <% end %>
35
+ <% asset_form.object.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
36
+ <%= asset_form.input field %>
37
+ <% end %>
38
+ <%= asset_form.input :asset_type, :as => :select, :collection => @page.asset_types %>
39
+ <%= asset_form.input :asset, :as => :file %>
40
+ <% end %>
41
+ <% end %>
42
+ </div>
14
43
  <% end %>
15
- <% end %>
16
- <% if @page.asset_types.length > 0 %>
17
- <%= form.semantic_fields_for :asset_items do |asset_form| %>
18
- <%= asset_form.inputs "Asset" do %>
19
- <% if asset_form.object.asset.present? %>
20
- <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
44
+
45
+ <div id="tabs-3">
46
+ <%= form.semantic_fields_for :publication do |pub| %>
47
+ <%= pub.inputs "Publication Settings" do %>
48
+ <%= pub.input :section, :as => :select, :required => false, :collection => current_site.sections unless current_site.sections.length == 0 %>
21
49
  <% end %>
22
- <% asset_form.object.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
23
- <%= asset_form.input field %>
50
+ <%= pub.inputs "Advanced Publication Settings" do %>
51
+ <%= pub.input :custom_slug, :required => false %>
52
+ <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
53
+ <%= pub.input :collection_scope, :required => false %>
54
+ <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
55
+ <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
56
+ <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
57
+ <%= pub.input :hide_in_submenu, :as => :boolean, :required => false %>
24
58
  <% end %>
25
- <%= asset_form.input :asset_type, :as => :select, :collection => @page.asset_types %>
26
- <%= asset_form.input :asset, :as => :file %>
27
59
  <% end %>
28
- <% end %>
29
- <% end %>
30
- <%= form.semantic_fields_for :publication do |pub| %>
31
- <%= pub.inputs "Publication Settings" do %>
32
- <%= pub.input :section, :as => :select, :required => false, :collection => current_site.sections unless current_site.sections.length == 0 %>
33
- <% end %>
34
- <%= pub.inputs "Advanced Publication Settings" do %>
35
- <%= pub.input :custom_slug, :required => false %>
36
- <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
37
- <%= pub.input :collection_scope, :required => false %>
38
- <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
39
- <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
40
- <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
41
- <%= pub.input :hide_in_submenu, :as => :boolean, :required => false %>
42
- <% end %>
43
- <% end %>
60
+ </div>
61
+ </div>
62
+
44
63
  <%= form.actions do %>
45
64
  <%= form.action :submit, :as => :button %>
46
- <%= form.action :cancel, :as => :link %>
47
65
  <% end %>
48
66
  <% end %>
@@ -1,9 +1,10 @@
1
1
  <li class="ui-state-default" id="page_<%= summary.id %>">
2
- <%= link_to summary.publication.slug, edit_manage_page_path(summary) %><br>
3
- <%= truncate(summary.title, :length => 80) %>
4
- <%= link_to summary.section.name if summary.section %>
5
- <%=l summary.updated_at, :format => :short %>
6
- <%= link_to "edit", edit_manage_page_path(summary) %>
7
- <%= link_to "show", manage_page_path(summary) %>
8
- <%= link_to "public", summary.path %>
2
+ <div class="controls">
3
+ <%= link_to "edit", edit_manage_page_path(summary), :class => "ui-icon ui-icon-pencil" %>
4
+ <%= link_to "public", summary.path, :class => "ui-icon ui-icon-newwin" %>
5
+ </div>
6
+ <%= link_to summary.title, edit_manage_page_path(summary) %><br>
7
+ <div class="details">
8
+ <%= truncate(summary.path, :length => 80) %> <span class="publication_date"><%=l summary.updated_at, :format => :short %></span>
9
+ </div>
9
10
  </li>
@@ -4,36 +4,51 @@
4
4
  <%= e %><br>
5
5
  <% end %>
6
6
  <% end %>
7
- <%= form.inputs @publishable_class.to_s do %>
8
- <% @publishable.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
9
- <%= form.input field %>
10
- <% end %>
11
- <% end %>
12
- <% if @publishable.asset_types.length > 0 %>
13
- <%= form.semantic_fields_for :asset_items do |asset_form| %>
14
- <%= asset_form.inputs "Asset" do %>
15
- <% if asset_form.object.asset.present? %>
16
- <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
7
+
8
+ <div id="tabs">
9
+ <ul>
10
+ <li><a href="#tabs-1"><%= @publishable.class.to_s.tableize.singularize.titleize %></a></li>
11
+ <li><a href="#tabs-2">Assets</a></li>
12
+ <li><a href="#tabs-3">Publication</a></li>
13
+ </ul>
14
+ <div id="tabs-1">
15
+ <%= form.inputs do %>
16
+ <div id="preview"></div>
17
+ <% @publishable.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
18
+ <%= form.input field %>
17
19
  <% end %>
18
- <% asset_form.object.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
19
- <%= asset_form.input field %>
20
+ <% end %>
21
+ </div>
22
+ <div id="tabs-2">
23
+ <% if @publishable.asset_types.length > 0 %>
24
+ <%= form.semantic_fields_for :asset_items do |asset_form| %>
25
+ <% if asset_form.object.asset.present? %>
26
+ <%= link_to(image_tag(asset_form.object.asset.url(:thumb)), asset_form.object.asset.url(:original), :target => "_new") %>
27
+ <% end %>
28
+ <%= asset_form.inputs "Asset" do %>
29
+ <% asset_form.object.editable_fields.collect{ |an| an.to_sym }.each do |field| %>
30
+ <%= asset_form.input field %>
31
+ <% end %>
32
+ <%= asset_form.input :asset_type, :as => :select, :collection => @publishable.asset_types %>
33
+ <%= asset_form.input :asset, :as => :file %>
34
+ <% end %>
20
35
  <% end %>
21
- <%= asset_form.input :asset_type, :as => :select, :collection => @publishable.asset_types %>
22
- <%= asset_form.input :asset, :as => :file %>
23
36
  <% end %>
24
- <% end %>
25
- <% end %>
26
- <%= form.semantic_fields_for :publication do |pub| %>
27
- <%= pub.inputs "Publication Settings" do %>
28
- <%= pub.input :custom_slug, :required => false %>
29
- <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
30
- <%= pub.input :collection_scope, :required => false %>
31
- <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
32
- <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
33
- <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
34
- <%= pub.input :hide_in_submenu, :as => :boolean, :required => false %>
35
- <% end %>
36
- <% end %>
37
+ </div>
38
+ <div id="tabs-3">
39
+ <%= form.semantic_fields_for :publication, @publishable.publication do |pub| %>
40
+ <%= pub.inputs "Advanced Publication Settings", :class => "advanced_settings" do %>
41
+ <%= pub.input :custom_slug, :required => false %>
42
+ <%= pub.input :collection_publishable_type_id, :as => :select, :collection => Publinator::PublishableType.all, :required => false %>
43
+ <%= pub.input :collection_scope, :required => false %>
44
+ <%= pub.input :publish_at, :as => :datetime_select, :required => false %>
45
+ <%= pub.input :unpublish_at, :as => :datetime_select, :required => false %>
46
+ <%= pub.input :archive_at, :as => :datetime_select, :required => false %>
47
+ <%= pub.input :hide_in_submenu, :as => :boolean, :required => false %>
48
+ <% end %>
49
+ <% end %>
50
+ </div>
51
+ </div>
37
52
  <%= form.actions do %>
38
53
  <%= form.action :submit, :as => :button %>
39
54
  <%= form.action :cancel, :as => :link %>
@@ -1,7 +1,10 @@
1
- <li class="ui-state-default" id="publishable_<%= summary.id %>">
2
- <%= link_to summary.my_slug, [:manage, summary] %><br>
3
- <%= summary.updated_at %> [
4
- <%= link_to "edit", send("edit_manage_#{@publishable_member_name}_path", summary) %>
5
- <%= link_to "show", [:manage, summary] %>
6
- <%= link_to "public", summary.path %> ]
1
+ <li class="ui-state-default" id="page_<%= summary.id %>">
2
+ <div class="controls">
3
+ <%= link_to "edit", send("edit_manage_#{@publishable_member_name}_path", summary), :class => "ui-icon ui-icon-pencil" %>
4
+ <%= link_to "public", summary.path, :class => "ui-icon ui-icon-newwin", :target => "_new" %>
5
+ </div>
6
+ <%= link_to summary.title, send("edit_manage_#{@publishable_member_name}_path", summary) %><br>
7
+ <div class="details">
8
+ <%= truncate(summary.path, :length => 80) %> <span class="publication_date"><%=l summary.updated_at, :format => :short %></span>
9
+ </div>
7
10
  </li>
@@ -1,7 +1,7 @@
1
- <h2><%= @publishable_class_name.capitalize.pluralize %></h2>
1
+ <h2><%= @publishable_class_name.tableize.titleize %></h2>
2
2
 
3
3
  <ul id="publishables">
4
4
  <%= render :collection => @publishables, :partial => "summary" %>
5
5
  </ul>
6
6
 
7
- <%= link_to "Add #{@publishable_class_name}", send("new_manage_#{@publishable_member_name}_path") %>
7
+ <%= link_to "Add #{@publishable_class_name.tableize.singularize.titleize}", send("new_manage_#{@publishable_member_name}_path"), :class => "new_button ui-button" %>
@@ -1,4 +1,4 @@
1
- <h2>Add a new <%= @publishable.class.to_s %></h2>
1
+ <h2>Add a new <%= @publishable.class.to_s.tableize.singularize.titleize %></h2>
2
2
 
3
3
  <%= render :partial => "form" %>
4
4
 
data/config/routes.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  Publinator::Engine.routes.draw do
2
2
 
3
3
  match "/manage" => 'manage#index'
4
+ match "/manage/preview" => 'manage#preview'
4
5
 
5
6
  namespace :manage do
6
7
 
@@ -8,6 +9,7 @@ Publinator::Engine.routes.draw do
8
9
  resources pt.name.tableize.to_sym, :controller => "publishable", :publishable_type => pt.name.tableize do
9
10
  member do
10
11
  post :sort
12
+ get :preview
11
13
  end
12
14
  end
13
15
  end
@@ -39,6 +41,7 @@ Publinator::Engine.routes.draw do
39
41
  resources :pages do
40
42
  collection do
41
43
  post :sort
44
+ post :preview
42
45
  end
43
46
  end
44
47
  resources :sites
data/lib/publinator.rb CHANGED
@@ -60,8 +60,12 @@ module Publinator
60
60
  []
61
61
  end
62
62
 
63
+ def hidden_fields
64
+ []
65
+ end
66
+
63
67
  def editable_fields
64
- attribute_names - ["id", "created_at", "updated_at"]
68
+ attribute_names - (["id", "created_at", "updated_at"] + hidden_fields)
65
69
  end
66
70
 
67
71
  def path
@@ -1,3 +1,3 @@
1
1
  module Publinator
2
- VERSION = "0.0.34"
2
+ VERSION = "0.0.35"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.34
4
+ version: 0.0.35
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-30 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -389,7 +389,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
389
389
  version: '0'
390
390
  segments:
391
391
  - 0
392
- hash: -2053584725192045846
392
+ hash: 1364858539637471117
393
393
  required_rubygems_version: !ruby/object:Gem::Requirement
394
394
  none: false
395
395
  requirements:
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
398
398
  version: '0'
399
399
  segments:
400
400
  - 0
401
- hash: -2053584725192045846
401
+ hash: 1364858539637471117
402
402
  requirements: []
403
403
  rubyforge_project:
404
404
  rubygems_version: 1.8.24