diff --git a/mods/digitalgazette/app/controllers/maps_controller.rb b/mods/digitalgazette/app/controllers/maps_controller.rb index 517c97c80..360431228 100644 --- a/mods/digitalgazette/app/controllers/maps_controller.rb +++ b/mods/digitalgazette/app/controllers/maps_controller.rb @@ -12,6 +12,7 @@ class MapsController < PagesController # TODO < ExternalPagesController include PagesHelper # FIXME: do we really need that "all" action? def index + @page_type = "map" render :template => 'pages/index' end diff --git a/mods/digitalgazette/app/controllers/search_controller.rb b/mods/digitalgazette/app/controllers/search_controller.rb index b6d587e0c..4b794b7e6 100644 --- a/mods/digitalgazette/app/controllers/search_controller.rb +++ b/mods/digitalgazette/app/controllers/search_controller.rb @@ -45,7 +45,6 @@ def render_search_results handle_rss(:title => full_url, :link => full_url, :image => (@user ? avatar_url(:id => @user.avatar_id||0, :size => 'huge') : nil)) - unless send_pages! # send the pages to the browser # museum during refactoring # if request.xhr? @@ -151,6 +150,7 @@ def send_pages! page[dom_id].replace_html(:partial => (partial = list_partial_for(:page_type => page_type)), :locals => { :pages => pages, + :page_type => page_type, :title => I18n.t("page_search_title".to_sym, :type => I18n.t("dg_#{page_type}".to_sym)), :no_top_pagination => true @@ -165,8 +165,6 @@ def send_pages! end end - - # # # OPTIONS & FILTERS @@ -191,7 +189,7 @@ def prefix_path # but used for iterative partial resolving of a group of page types def list_partial_for(options={ }) ret = - if options[:wrapper] ||= @wrapper + if options[:wrapper] ||= @wrapper LEGAL_PARTIALS[options[:wrapper].to_s] elsif options[:widget] ||= @widget BOX_PARTIALS[options[:widget].to_s] || "" @@ -282,39 +280,6 @@ def get_page_types @page_type = @page_types.first if @page_types.size == 1 end - # general update method - # sends the right partials to the browser - # therefore takes the Hash in @pages an resolves it - # to the pages/list or the widget/panel - specific partials - # - # TODO implement non-xhr fallback by passing - # the relevant widget-tree - # down to clever partials/helpers - # - def send_pages! - if request.xhr? - # Update every widget as one, if existing - render :update do |page| - @page_store.to_hash.each_pair do |page_type,options| - dom_id = options[:dom_id] - pages = options[:pages] - page[dom_id].replace_html(:partial => (partial = list_partial_for(:page_type => page_type)), - :locals => { - :pages => pages, - :title => I18n.t("page_search_title".to_sym, - :type => I18n.t("dg_#{page_type}".to_sym)), - :no_top_pagination => true - } ) - page[dom_id].insert( { :after => panel_pagination_at(:bottom, options)}) - logger.debug("REPLACING '#{dom_id}' WITH PARTIAL '#{partial}'. HAVE #{pages.size} PAGES OF TYPE '#{page_type}'. CURRENT PAGE #{params[:page].inspect} PER PAGE #{params[:per_page].inspect}") - end - if @panel && params[:pagination] - page["#{@panel}_pagination_bottom"].replace_html(panel_pagination_at(:bottom, { :pagination => params[:pagination], :path => @path.to_param})) - end - end - end - end - # the @page_store is our widget tree def setup_page_store diff --git a/mods/digitalgazette/app/helpers/application_helper.rb b/mods/digitalgazette/app/helpers/application_helper.rb index dcc181a81..e5edcc172 100644 --- a/mods/digitalgazette/app/helpers/application_helper.rb +++ b/mods/digitalgazette/app/helpers/application_helper.rb @@ -1,7 +1,4 @@ module ApplicationHelper - - - def page_line page, &block "
  • #{yield}
  • " end @@ -15,13 +12,22 @@ def pagination_for(things, options={}) else defaults = {:renderer => LinkRenderer::Dispatch, :previous_label => "« %s" % I18n.t(:pagination_previous), :next_label => "%s »" % I18n.t(:pagination_next), :inner_window => 2} end + # if a @page_type is given, we only want to render this, so we have to overwrite + # the current path, to exclue other page_types + if options[:page_type] + # if we pass a path option to will paginate, it will use it for creating the url + # see lib/digital_gazette/will_paginate_ajax_link_renderer.rb + options[:params] ||= {} + options[:params][:path] = @naked_path.dup + options[:params][:path].add_types!(options[:page_type]) + options[:params][:path].flatten! + end will_paginate(things, defaults.merge(options)) end # i had problems, this does exactly, what i want def better_hidden_field group, name, value "" - end def clean_javascript_string(string, quote) diff --git a/mods/digitalgazette/app/views/pages/_list.html.haml b/mods/digitalgazette/app/views/pages/_list.html.haml index eb6af0125..33c7d2495 100644 --- a/mods/digitalgazette/app/views/pages/_list.html.haml +++ b/mods/digitalgazette/app/views/pages/_list.html.haml @@ -3,7 +3,6 @@ - # it basically adds logic to handel @maps seperated from pages - pages ||= @pages = render(:partial => heading_partial) if local_assigns[:heading_partial] - %section#pages{:class=> local_assigns[:full_width] ? 'full' : ''} %header - if local_assigns[:title] && !title.blank? @@ -11,9 +10,9 @@ = title %div.right = render(:partial => pages_dropdown) if local_assigns[:pages_dropdown] - = pagination_for(pages, :method => 'get') unless local_assigns[:no_top_pagination] + = pagination_for(pages, :method => 'get', :page_type => local_assigns[:page_type]) unless local_assigns[:no_top_pagination] - else - = pagination_for(pages, :method => 'get') unless local_assigns[:no_top_pagination] + = pagination_for(pages, :method => 'get', :page_type => local_assigns[:page_type]) unless local_assigns[:no_top_pagination] - if pages && pages.any? = render(:partial => block_above_pages_list_partial) if local_assigns[:block_above_pages_list_partial] @@ -25,4 +24,4 @@ - if defined?(pagination_link) && pagination_link.present? %span.pagination - else - = pagination_for(pages, :method => 'get') + = pagination_for(pages, :method => 'get', :page_type => local_assigns[:page_type]) diff --git a/mods/digitalgazette/app/views/pages/_tags.html.erb b/mods/digitalgazette/app/views/pages/_tags.html.erb index 3bf6b1776..2bc21a31b 100644 --- a/mods/digitalgazette/app/views/pages/_tags.html.erb +++ b/mods/digitalgazette/app/views/pages/_tags.html.erb @@ -1,5 +1,5 @@ diff --git a/mods/digitalgazette/app/views/pages/_topics.html.haml b/mods/digitalgazette/app/views/pages/_topics.html.haml index 3a54d0192..7a96d6c79 100644 --- a/mods/digitalgazette/app/views/pages/_topics.html.haml +++ b/mods/digitalgazette/app/views/pages/_topics.html.haml @@ -1,7 +1,5 @@ -tags ||= {:politics => ["Conflict","Judicial System","Law Enforcement" ,"Military","Public Administration","Political Parties"], :society => ["Gender","Livelihoods and Land Use","Non-Pakhtuns","Pakhtuns","Socio-economic Classes","Youth"], :religion => ["Other Religious Sects","Religious Political Movements","Shia Belief and Practice","Sufi Belief and Practice","Sunni Belief and Practice"], :development => ["Agriculture","Civil Society","Communication","Economy","Education","Energy","Health","Housing","Humanitarian Response","Natural Resources","Transport","Social Welfare","Water Supply and Sanitation"]} - - %div#browse_topics %div.political_topics = render :partial => "/pages/tag_category", :locals => {:asset_type => page_type, :category => "Politics", :tags => tags[:politics]} diff --git a/mods/digitalgazette/app/views/pages/index.html.haml b/mods/digitalgazette/app/views/pages/index.html.haml index 8cdf093f7..f0e058e5f 100644 --- a/mods/digitalgazette/app/views/pages/index.html.haml +++ b/mods/digitalgazette/app/views/pages/index.html.haml @@ -1,7 +1,6 @@ = render :partial => "pages/#{@page_type.underscore}/header" = render :partial => 'search/banner', :locals => {:page_type => @page_type} /= render :partial => 'pages/search', :locals => {:users => @user.friends, :groups => @user.groups} - %div#browse %h4= "... or Browse #{@page_type.pluralize} by Topic" = render :partial => 'pages/topics', :locals => { :page_type => (@page_type || "WikiPage") } diff --git a/mods/digitalgazette/lib/digital_gazette/#pages_controller_extension.rb# b/mods/digitalgazette/lib/digital_gazette/#pages_controller_extension.rb# new file mode 100644 index 000000000..c3266b916 --- /dev/null +++ b/mods/digitalgazette/lib/digital_gazette/#pages_controller_extension.rb# @@ -0,0 +1,16 @@ +module DigitalGazette + module PagesControllerExtension + def self.included(base) + base.instance_eval do + skip_before_filter :login_required + before_filter :public_or_login_required, :except => [:search] + end + end + + def public_or_login_required + return true unless @pages + !(@pages.collect {|p| p.public? }.include?(false)) or login_required + end + end +end +xx \ No newline at end of file diff --git a/mods/digitalgazette/lib/digital_gazette/.#pages_controller_extension.rb b/mods/digitalgazette/lib/digital_gazette/.#pages_controller_extension.rb new file mode 120000 index 000000000..2816d2761 --- /dev/null +++ b/mods/digitalgazette/lib/digital_gazette/.#pages_controller_extension.rb @@ -0,0 +1 @@ +jrw@sublime.7792:1286441298 \ No newline at end of file