From d72edba966ba2b55697685f3711dbfcb38d9fbc8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 5 Feb 2025 22:48:19 +0100 Subject: fix edit node behaviour --- public/javascripts/admin_search.js | 123 +++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 54 deletions(-) (limited to 'public/javascripts') diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 6d3ca93..98571de 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js @@ -1,12 +1,12 @@ admin_search = { - + initialize : function() { $(document).bind("keydown", 'Alt+f', function(){ admin_search.display_toggle(); return false; }); }, - + display_toggle : function() { if ($('#search_widget').css("display") != "none") { $('#search_widget').fadeOut(); @@ -16,7 +16,7 @@ admin_search = { $('#search_term').attr("value", ""); $('#search_term').focus(); } - + $("#search_term").bind("keyup", function() { if ($(this).attr("value")) { $.ajax({ @@ -31,11 +31,11 @@ admin_search = { } else { $('#search_results').slideUp(); - $('#search_results').empty(); + $('#search_results').empty(); } }); }, - + show_results : function(results) { $('#search_results').empty(); for (result in results) { @@ -46,7 +46,7 @@ admin_search = { }; menu_items = { - + initialize_search : function() { $("#menu_search_term").bind("keyup", function() { if ($(this).attr("value")) { @@ -62,28 +62,28 @@ menu_items = { } else { $('#search_results').slideUp(); - $('#search_results').empty(); + $('#search_results').empty(); } }); }, - + show_results : function(results) { $("#search_results").empty(); for (result in results) { var link = $((""+ results[result].title + "")); $(link).bind("click", menu_items.link_closure(results[result])); - - + + // Sometimes I don't get jquery; wrap() didn't work *sigh* // Guess I'll need a book someday or another framework var wrapper = $("
"); $(wrapper).append(link) - + $("#search_results").append(wrapper); - + } }, - + link_closure : function(node) { var barf = function(){ $("#menu_item_node_id").val(node.node_id); @@ -91,7 +91,7 @@ menu_items = { $("#menu_item_title").val(node.title); return false; } - + return barf; } }; @@ -99,7 +99,7 @@ menu_items = { parent_search = { initialize_search : function() { parent_search.initialize_radio_buttons(); - + $("#parent_search_term").bind("keyup", function() { if ($(this).attr("value")) { $.ajax({ @@ -114,28 +114,31 @@ parent_search = { } else { $('#search_results').slideUp(); - $('#search_results').empty(); + $('#search_results').empty(); } }); }, - + show_results : function(results) { $("#search_results").empty(); + var found = false; for (result in results) { var link = $((""+ results[result].title + "")); $(link).bind("click", parent_search.link_closure(results[result])); - - + + // Sometimes I don't get jquery; wrap() didn't work *sigh* // Guess I'll need a book someday or another framework var wrapper = $("
"); - $(wrapper).append(link) - + $(wrapper).append(link); + $("#search_results").append(wrapper); - + found = true; } + if (found) + $('#search_results').slideDown(); }, - + link_closure : function(node) { var barf = function(){ $("#parent_search_term").attr("value", node.title); @@ -144,64 +147,76 @@ parent_search = { $('#search_results').empty(); return false; } - + return barf; }, - + initialize_radio_buttons : function() { $("#kind_top_level").bind("change", function(){ $("#parent_search_field").hide(); }); - + $("#kind_update").bind("change", function(){ $("#parent_search_field").hide(); }); - + $("#kind_generic").bind("change", function(){ $("#parent_search_field").show(); }); - + } } move_to_search = { - initialize_search : function() { - $("#move_to_search_term").bind("keyup", function() { - if ($(this).attr("value")) { - $.ajax({ - type: "GET", - url: "/admin/menu_search", - data: "search_term=" + $(this).attr("value"), - dataType: "json", - success : function(results) { - move_to_search.show_results(results); - } - }); - } - else { - $('#search_results').slideUp(); - $('#search_results').empty(); - } - }); + initialize_search : function() { + $("#move_to_search_term").bind("keyup", function() { move_to_search.do_search($(this))}); + $("#move_to_search_term").bind("keydown", function() { move_to_search.do_search($(this))}); + $("#move_to_search_term").bind("keypress", function() { move_to_search.do_search($(this))}); + $("#move_to_search_term").bind("paste", function() { move_to_search.do_search($(this))}); + $("#move_to_search_term").bind("cut", function() { move_to_search.do_search($(this))}); }, - + + do_search : function(_this) { + if (_this.attr("value")) { + $.ajax({ + type: "GET", + url: "/admin/menu_search", + data: "search_term=" + _this.attr("value"), + dataType: "json", + success : function(results) { + move_to_search.show_results(results); + } + }); + } + else { + $('#search_results').slideUp(); + $('#search_results').empty(); + } + }, + show_results : function(results) { $("#search_results").empty(); + var found = false; for (result in results) { var link = $((""+ results[result].title + "")); $(link).bind("click", move_to_search.link_closure(results[result])); - - + + // Sometimes I don't get jquery; wrap() didn't work *sigh* // Guess I'll need a book someday or another framework var wrapper = $("
"); $(wrapper).append(link) - + $("#search_results").append(wrapper); - + found = true; } + if (found) + $('#search_results').slideDown(); + else + $('#search_results').slideUp(); + }, - + link_closure : function(node) { var barf = function(){ $("#move_to_search_term").attr("value", node.title); @@ -210,7 +225,7 @@ move_to_search = { $('#search_results').empty(); return false; } - + return barf; } -} \ No newline at end of file +} -- cgit v1.3 From 8199b48ae5d31b008f10dff173352bd8ba2d8890 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 5 Feb 2025 23:04:13 +0100 Subject: Enhance admin view by sitemap --- app/controllers/admin_controller.rb | 7 +++++++ app/views/admin/index.html.erb | 37 +++++++++++++++++++++++++++++++++-- public/javascripts/admin_interface.js | 17 +++++++++++++++- public/stylesheets/admin.css | 4 ++++ 4 files changed, 62 insertions(+), 3 deletions(-) (limited to 'public/javascripts') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index cdfe564..7c1375a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -17,6 +17,13 @@ class AdminController < ApplicationController "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days ] ) + + all_nodes = Node.root.self_and_descendants + @sitemap_depth = {} + Node.each_with_level(all_nodes) do |node, level| + @sitemap_depth[node.id] = level + end + @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } end def search diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 526aa88..8c8271f 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,6 +1,7 @@

recent changes current drafts + site map

@@ -64,9 +65,41 @@ <%= node.lock_owner.login if node.lock_owner %> - <%= node.draft ? node.draft.revision : node.head.revision %> + <%= node.draft ? node.draft.revision : ( node.head ? node.head.revision : "EMPTY" ) %> <% end %> -
\ No newline at end of file + + +
+ +

Sitemap

+ + + + + + + + + <% @sitemap.each do |node| %> + <% if !node.nil? %> + "> + + + + + + <% end %> + <% end %> +
IDTitleActionsLocked by
<%= node.id %> +

<%= link_to title_for_node(node), node_path(node) %>

+

<%= link_to_path(node.unique_name, node.unique_name) %>

+
+ <%= link_to 'show', node_path(node) %> + <%= link_to 'Revisions', node_revisions_path(node) %> + + <%= node.lock_owner.login if node.lock_owner %> +
+
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index f8148e2..ea3ab3d 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js @@ -16,7 +16,7 @@ $(document).ready(function () { theme_advanced_buttons1 : "bold, italic, underline, bullist, numlist, link, unlink, formatselect, code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", - extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial]", + extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial|conditions]", relative_urls : false, entity_encoding : "raw", oninit : cccms.setup_autosave() @@ -44,21 +44,36 @@ $(document).ready(function () { if ($('#recent_changes_toggle').length != 0) { $('#current_drafts_table').hide(); + $('#admin_sitemap_table').hide(); $('#recent_changes_toggle').attr("class", "selected"); $('#recent_changes_toggle').bind("click", function(){ $('#recent_changes_toggle').attr("class", "selected"); $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); $('#recent_changes_table').show(); $('#current_drafts_table').hide(); + $('#admin_sitemap_table').hide(); return false; }); $('#current_drafts_toggle').bind("click", function(){ $('#recent_changes_toggle').attr("class", "unselected"); $('#current_drafts_toggle').attr("class", "selected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); $('#current_drafts_table').show(); $('#recent_changes_table').hide(); + $('#admin_sitemap_table').hide(); + return false; + }); + + $('#admin_sitemap_toggle').bind("click", function(){ + $('#recent_changes_toggle').attr("class", "unselected"); + $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "selected"); + $('#current_drafts_table').hide(); + $('#recent_changes_table').hide(); + $('#admin_sitemap_table').show(); return false; }); } diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index f95fa18..fbb8a3f 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -170,6 +170,10 @@ table.node_table .actions { text-transform: lowercase; } +#admin_sitemap_table .node_id:before { + content: "• "; +} + /* Revisions */ table#revisions { -- cgit v1.3 From 375ed745052148faeb34763087fe04214105f1b8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 6 Feb 2025 16:49:06 +0100 Subject: Improve worklflow --- app/controllers/admin_controller.rb | 18 ++++++++++-- app/controllers/nodes_controller.rb | 15 +++++++++- app/views/admin/index.html.erb | 48 ++++++++++++++++++++++++++++++-- app/views/nodes/new.html.erb | 12 +++++--- public/javascripts/admin_interface.js | 52 +++++++++++++++++++++++++---------- public/javascripts/admin_search.js | 4 +++ public/stylesheets/admin.css | 16 +++++++++++ 7 files changed, 141 insertions(+), 24 deletions(-) (limited to 'public/javascripts') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7c1375a..f3cc221 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -6,12 +6,15 @@ class AdminController < ApplicationController def index @drafts = Node.all( - :limit => 20, + :limit => 50, :order => "updated_at desc", :conditions => ["draft_id IS NOT NULL"] ) + @drafts_count = Node.count( + :conditions => ["draft_id IS NOT NULL"] + ) @recent_changes = Node.all( - :limit => 20, + :limit => 50, :order => "updated_at desc", :conditions => [ "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days @@ -24,6 +27,17 @@ class AdminController < ApplicationController @sitemap_depth[node.id] = level end @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } + + @mypages = Page.all( + :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user] + ) + + @mynodes = Node.all( + :order => "updated_at desc", + :joins => :pages, + :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ] + ).uniq.first(50) + end def search diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 4f72744..b8cd644 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -25,6 +25,10 @@ class NodesController < ApplicationController def new @node = Node.new params[:node] + if params.has_key?(:parent_id) + @parent_id = params[:parent_id] + @parent_name = Node.find(@parent_id).title + end end def create @@ -33,9 +37,16 @@ class NodesController < ApplicationController @node = Node.new @node.parent_id = find_parent @node.slug = params[:title].parameterize.to_s - + if @node.save @node.draft.update_attributes(:title => params[:title]) + case params[:kind] + when "update" + @node.draft.tag_list.add("update") + when "press_release" + @node.draft.tag_list.add("update", "pressemitteilung") + end + @node.draft.save! redirect_to(edit_node_path(@node)) else render :new @@ -107,6 +118,8 @@ class NodesController < ApplicationController Node.root.id when "update" Update.find_or_create_parent.id + when "press_release" + Update.find_or_create_parent.id when "generic" if params[:parent_id] && Node.find(params[:parent_id]) params[:parent_id] diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 8c8271f..edad1d6 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,5 +1,13 @@ +
+ <%= link_to 'Create Update or Pressemitteilung', new_node_path, :only_path => false %> + Continue my work + Add a page in the page tree + <%= link_to("Upload a new asset", new_asset_path, :only_path => false) %> +
+

recent changes + my work current drafts site map

@@ -38,9 +46,43 @@ +
+ +

My Work

+ + + + + + + + + + <% @mynodes.each do |node| %> + "> + + + + + + + <% end %> +
IDTitleActionsLocked byRev.
<%= node.id %> +

<%= link_to title_for_node(node), node_path(node) %>

+

<%= link_to_path(node.unique_name, node.unique_name) %>

+
+ <%= link_to 'show', node_path(node) %> + <%= link_to 'Revisions', node_revisions_path(node) %> + + <%= node.lock_owner.login if node.lock_owner %> + + <%= node.draft ? node.draft.revision : node.head.revision %> +
+
+
-

Current Drafts

+

Current Drafts (<%= @drafts_count %>)

@@ -92,8 +134,8 @@

<%= link_to_path(node.unique_name, node.unique_name) %>

@@ -31,8 +35,8 @@
- <%= link_to 'show', node_path(node) %> - <%= link_to 'Revisions', node_revisions_path(node) %> + <%= link_to 'create subpage', new_node_path(:parent_id => node.id) %> + <%= link_to ':: Revisions', node_revisions_path(node) %> <%= node.lock_owner.login if node.lock_owner %> diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index 850207b..7d744de 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb @@ -20,7 +20,11 @@

<%= radio_button_tag :kind, "update" %> - Update / Press release ( is automatically created in /updates ) + Update ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tag "update" ) +

+

+ <%= radio_button_tag :kind, "press_release" %> + Pressemitteilung ( is automatically created in /updates/<%= Time.now.year.to_s %>/ and gets tags "update, pressemitteilung" )

Parent - <%= text_field_tag :parent_search_term %> - <%= hidden_field_tag :parent_id %> + <%= text_field_tag :parent_search_term, @parent_name %> + <%= hidden_field_tag :parent_id, @parent_id %>
@@ -43,4 +47,4 @@
<%= submit_tag "Create" %>
-<% end %> \ No newline at end of file +<% end %> diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index ea3ab3d..aacb6f8 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js @@ -1,3 +1,15 @@ +function hide_all() { + $('#recent_changes_toggle').attr("class", "unselected"); + $('#my_work_toggle').attr("class", "unselected"); + $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); + + $('#current_drafts_table').hide(); + $('#my_work_table').hide(); + $('#recent_changes_table').hide(); + $('#admin_sitemap_table').hide(); +} + $(document).ready(function () { admin_search.initialize(); @@ -43,36 +55,48 @@ $(document).ready(function () { } if ($('#recent_changes_toggle').length != 0) { - $('#current_drafts_table').hide(); - $('#admin_sitemap_table').hide(); + hide_all(); $('#recent_changes_toggle').attr("class", "selected"); + $('#recent_changes_table').show(); $('#recent_changes_toggle').bind("click", function(){ + hide_all(); $('#recent_changes_toggle').attr("class", "selected"); - $('#current_drafts_toggle').attr("class", "unselected"); - $('#admin_sitemap_toggle').attr("class", "unselected"); $('#recent_changes_table').show(); - $('#current_drafts_table').hide(); - $('#admin_sitemap_table').hide(); + return false; + }); + + $('#my_work_toggle').bind("click", function(){ + hide_all(); + $('#my_work_toggle').attr("class", "selected"); + $('#my_work_table').show(); + return false; + }); + + $('#admin_wizard_my_work').bind("click", function(){ + hide_all(); + $('#my_work_toggle').attr("class", "selected"); + $('#my_work_table').show(); return false; }); $('#current_drafts_toggle').bind("click", function(){ - $('#recent_changes_toggle').attr("class", "unselected"); + hide_all(); $('#current_drafts_toggle').attr("class", "selected"); - $('#admin_sitemap_toggle').attr("class", "unselected"); $('#current_drafts_table').show(); - $('#recent_changes_table').hide(); - $('#admin_sitemap_table').hide(); return false; }); $('#admin_sitemap_toggle').bind("click", function(){ - $('#recent_changes_toggle').attr("class", "unselected"); - $('#current_drafts_toggle').attr("class", "unselected"); + hide_all(); + $('#admin_sitemap_toggle').attr("class", "selected"); + $('#admin_sitemap_table').show(); + return false; + }); + + $('#admin_wizard_create_page').bind("click", function(){ + hide_all(); $('#admin_sitemap_toggle').attr("class", "selected"); - $('#current_drafts_table').hide(); - $('#recent_changes_table').hide(); $('#admin_sitemap_table').show(); return false; }); diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 98571de..78577e7 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js @@ -160,6 +160,10 @@ parent_search = { $("#parent_search_field").hide(); }); + $("#kind_press_release").bind("change", function(){ + $("#parent_search_field").hide(); + }); + $("#kind_generic").bind("change", function(){ $("#parent_search_field").show(); }); diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index fbb8a3f..c7ebb52 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -106,6 +106,22 @@ input[type=submit], text-transform: lowercase; } +#admin_wizard { + margin-bottom: 2rem; +} + +#admin_wizard a { + font-size: 1rem; + font-weight: bold; + padding: 0.5rem; + background-color: green; + color: white; +} + +#admin_wizard a:hover { + background-color: lime; +} + #sub_navigation a { color: #969696; } -- cgit v1.3 From 6424e10be5a89f175a74c71c55660412a169b8b8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 23 Jun 2026 18:04:37 +0200 Subject: Update deployed state to what's currently running --- Rakefile | 4 +- app/controllers/nodes_controller.rb | 1 + app/helpers/admin_helper.rb | 4 +- app/helpers/content_helper.rb | 6 +- app/models/node.rb | 29 +- app/models/page.rb | 15 +- app/views/admin/index.html.erb | 18 +- app/views/content/_featured_articles.html.erb | 6 +- app/views/content/_main_navigation.html.erb | 6 - app/views/content/_search.html.erb | 9 +- app/views/content/_tags.html.erb | 4 +- app/views/layouts/application.html.erb | 43 ++- app/views/nodes/edit.html.erb | 156 ++++----- config/database.mysql-sample.yml | 45 --- config/database.psql-sample.yml | 51 --- config/environments/production.rb | 2 +- config/locales/de.yml | 1 + config/locales/en.yml | 6 +- public/javascripts/public.js | 9 +- public/stylesheets/admin.css | 202 +++++++++--- public/stylesheets/ccc.css | 363 +++++++++++++++------ test/functional/nodes_controller_test.rb | 36 ++ vendor/plugins/paperclip/lib/paperclip/geometry.rb | 1 + 23 files changed, 637 insertions(+), 380 deletions(-) delete mode 100644 config/database.mysql-sample.yml delete mode 100644 config/database.psql-sample.yml (limited to 'public/javascripts') diff --git a/Rakefile b/Rakefile index 3af2c3a..b8e1d62 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,9 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' -require 'rake/rdoctask' + +#require 'rake/rdoctask' +#require 'rdoc/task' require 'tasks/rails' require 'thinking_sphinx/tasks' diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index b8cd644..95aed48 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -55,6 +55,7 @@ class NodesController < ApplicationController def show node = Node.find(params[:id]) + node.wipe_draft! @page = node.draft || node.head end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 232862b..389f6dc 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -3,9 +3,9 @@ module AdminHelper def language_selector case I18n.locale when :de - link_to 'English (Aktiv: Deutsch)', url_for(:overwrite_params => {:locale => :en}) + link_to raw('English'), url_for(:overwrite_params => {:locale => :en}) when :en - link_to 'Deutsch (Active: English)', url_for(:overwrite_params => {:locale => :de}) + link_to raw('Deutsch'), url_for(:overwrite_params => {:locale => :de}) end end end diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 7286976..17364f8 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -43,7 +43,7 @@ module ContentHelper # Returns the published_at attribute of a page if it is not nil, otherwise # it returns the auto-filled value of the created_at attribute def date_for_page page - page.published_at.to_s(:db) rescue page.created_at.to_s(:db) + I18n.l(page.published_at, :format => :ccc) rescue I18n.l(page.created_at, :format => :ccc) end def author_for_page page @@ -80,10 +80,10 @@ module ContentHelper begin if content =~ /]*)>/ tag = $~.to_s - matched_data = $1.scan(/\w+\=\"[a-zA-Z\s\/_\d,]*\"/) + matched_data = $1.scan(/\w+\=\"[a-zA-Z\s\/_\d,.=]*\"/) matched_data.each do |data| - splitted_data = data.split("=") + splitted_data = data.split("=", 2) options[splitted_data[0].to_sym] = splitted_data[1].gsub(/\"/, "") end diff --git a/app/models/node.rb b/app/models/node.rb index 6c11fed..75122d1 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -3,11 +3,11 @@ class Node < ActiveRecord::Base acts_as_nested_set # Associations - has_many :pages, :order => "revision ASC" - belongs_to :head, :class_name => "Page", :foreign_key => :head_id - belongs_to :draft, :class_name => "Page", :foreign_key => :draft_id - has_many :permissions - has_one :event + has_many :pages, :order => "revision ASC", :dependent => :destroy + belongs_to :head, :class_name => "Page", :foreign_key => :head_id, :dependent => :destroy + belongs_to :draft, :class_name => "Page", :foreign_key => :draft_id, :dependent => :destroy + has_many :permissions, :dependent => :destroy + has_one :event, :dependent => :destroy belongs_to :lock_owner, :class_name => "User", :foreign_key => :locking_user_id # Callbacks @@ -60,6 +60,7 @@ class Node < ActiveRecord::Base # Instance Methods def find_or_create_draft current_user + self.wipe_draft! if draft && self.lock_owner == current_user draft elsif draft && self.lock_owner.nil? @@ -115,6 +116,24 @@ class Node < ActiveRecord::Base end end + # removes a draft and the lock if it is older than a day and still + # identical to head + def wipe_draft! + unless self.draft + self.unlock! + return + end + return unless self.head + return unless self.draft.updated_at < 1.day.ago + return if Page.find(self.head).has_changes_to? self.draft + + self.draft.destroy + self.draft_id = nil + self.unlock! + self.save! + self.reload + end + def restore_revision! revision if page = self.pages.find_by_revision(revision) self.head = page diff --git a/app/models/page.rb b/app/models/page.rb index 0cfad53..f804353 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -64,7 +64,7 @@ class Page < ActiveRecord::Base Page.heads.paginate( find_options_for_find_tagged_with( - options[:tags].gsub(/\s/, ","), :match_all => true + options[:tags].gsub(/\s/, ","), :match_all => true, :conditions => options[:conditions] ).merge( :page => page, :per_page => options[:limit], @@ -94,6 +94,19 @@ class Page < ActiveRecord::Base end end + # Is used to compare a node's head with the node's draft + + def has_changes_to? draft + return true unless node == draft.node + return true unless assets == draft.assets + return true unless tag_list == draft.tag_list + return true unless template_name == draft.template_name + return true unless translated_locales.sort_by(&:to_s) == draft.translated_locales.sort_by(&:to_s) + changed = false + translated_locales.each { |locale| I18n.with_locale(locale) { changed = true unless title == draft.title && abstract == draft.abstract && body == draft.body } } + return changed + end + # Instance Methods def public_template_path diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index edad1d6..2741db3 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,14 +1,14 @@
- <%= link_to 'Create Update or Pressemitteilung', new_node_path, :only_path => false %> - Continue my work - Add a page in the page tree - <%= link_to("Upload a new asset", new_asset_path, :only_path => false) %> +
<%= link_to 'Create Update or Pressemitteilung', new_node_path, :only_path => false %>
+ + +
<%= link_to("Upload a new asset", new_asset_path, :only_path => false) %>

recent changes my work - current drafts + current drafts (<%= @drafts_count %>) site map

@@ -39,7 +39,7 @@ <%= node.lock_owner.login if node.lock_owner %> - <%= node.draft ? node.draft.revision : node.head.revision %> + <%= link_to ( node.draft ? node.draft.revision : (node.head ? node.head.revision : "EMPTY" ) ), node_revisions_path(node) %> <% end %> @@ -73,7 +73,7 @@ <%= node.lock_owner.login if node.lock_owner %> - <%= node.draft ? node.draft.revision : node.head.revision %> + <%= link_to ( node.draft ? node.draft.revision : (node.head ? node.head.revision : "EMPTY" ) ), node_revisions_path(node) %> <% end %> @@ -107,7 +107,7 @@ <%= node.lock_owner.login if node.lock_owner %> - <%= node.draft ? node.draft.revision : ( node.head ? node.head.revision : "EMPTY" ) %> + <%= link_to ( node.draft ? node.draft.revision : (node.head ? node.head.revision : "EMPTY" ) ), node_revisions_path(node) %> <% end %> @@ -135,7 +135,7 @@ <%= link_to 'create subpage', new_node_path(:parent_id => node.id) %> - <%= link_to ':: Revisions', node_revisions_path(node) %> + <%= link_to 'Revisions', node_revisions_path(node) %> <%= node.lock_owner.login if node.lock_owner %> diff --git a/app/views/content/_featured_articles.html.erb b/app/views/content/_featured_articles.html.erb index 0220abb..c69911f 100644 --- a/app/views/content/_featured_articles.html.erb +++ b/app/views/content/_featured_articles.html.erb @@ -11,7 +11,7 @@ <%= link_to( image_tag( 'chaosradio.png' ), - "http://chaosradio.ccc.de/", + "https://chaosradio.ccc.de/", :id => "chaosradio_icon", :title => "Chaosradio" )%> @@ -25,14 +25,14 @@ <%= link_to( image_tag( 'ds.png' ), - "http://ds.ccc.de/", + "https://ds.ccc.de/", :id => "ds_icon", :title => "Datenschleuder" )%> <%= link_to( image_tag( 'events.png' ), - "http://events.ccc.de/", + "https://events.ccc.de/", :id => "events_icon", :title => "Events Blog" )%> diff --git a/app/views/content/_main_navigation.html.erb b/app/views/content/_main_navigation.html.erb index a984512..2fe8b77 100644 --- a/app/views/content/_main_navigation.html.erb +++ b/app/views/content/_main_navigation.html.erb @@ -3,11 +3,5 @@ <% menu_items.each do |item| %>
  • <%= link_to_path item.title, item.path %>
  • <% end %> -
  • - <%= language_selector %> -
  • -
  • - -
  • diff --git a/app/views/content/_search.html.erb b/app/views/content/_search.html.erb index 9f61042..e654462 100644 --- a/app/views/content/_search.html.erb +++ b/app/views/content/_search.html.erb @@ -1,8 +1,3 @@ <% form_tag search_path, :method => 'get' do %> - - - - - -
    <%= text_field_tag :search_term, params[:search_term] %><%= image_submit_tag("search_button.png") %>
    -<% end %> \ No newline at end of file +
    <%= text_field_tag :search_term, params[:search_term], :placeholder => 'suchen', :type => 'search' %>
    +<% end %> diff --git a/app/views/content/_tags.html.erb b/app/views/content/_tags.html.erb index d33bc10..fd808b6 100644 --- a/app/views/content/_tags.html.erb +++ b/app/views/content/_tags.html.erb @@ -1,3 +1,4 @@ +<% unless @page.tags.empty? %>

    Tags

      @@ -5,4 +6,5 @@
    • <%= link_to tag.name, tag_path(:id => tag.name) %>
    • <% end %>
    -
    \ No newline at end of file + +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 915091d..d2a624f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,11 +1,10 @@ - + - + @@ -19,21 +18,45 @@ <%= auto_discovery_link_tag(:atom, {:locale => :de, :controller => "rss", :action => "updates", :format => :xml}) %> <%= auto_discovery_link_tag(:rss, {:locale => :de, :controller => "rss", :action => "updates", :format => :rdf}) %> + + +
    -