Class: PageinfoController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PageinfoController
- Defined in:
- app/controllers/pageinfo_controller.rb
Overview
COPYRIGHT:
Copyright © 2005-2011 North Carolina State University Developed with funding for the National eXtension Initiative.
LICENSE:
BSD(-compatible) see LICENSE file or view at about.extension.org/wiki/LICENSE
Instance Method Summary (collapse)
- - (Object) find_by_source
- - (Object) page_csvlist(articlelist, filename, content_tag)
- - (Object) pagelinklist
- - (Object) pagelist
- - (Object) show
Methods inherited from ApplicationController
#content_date_sort, #do_404, #do_410, #do_invalid_page, #get_county_options, #get_location_options, #mobile_detection, #set_analytics_visitor, #set_app_location, #set_default_request_ip_address, #set_locale, #set_request_url_options, #unescape_params
Methods included from ControllerExtensions
#check_openidurl_foruser, #log_user_activity, #validate_datepicker
Methods included from AuthLib
#current_person, #set_current_person
Instance Method Details
- (Object) find_by_source
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/pageinfo_controller.rb', line 15 def find_by_source @right_column = false source_name = params[:source_name] source_id = params[:source_id] if(!source_name.blank? and !source_id.blank?) @page = Page.find_by_source_name_and_id(source_name,source_id) if(@page) return redirect_to pageinfo_page_url(:id => @page.id) else flash.now[:error] = "Unable to find a page with that source and node id" end end end |
- (Object) page_csvlist(articlelist, filename, content_tag)
136 137 138 139 140 141 142 |
# File 'app/controllers/pageinfo_controller.rb', line 136 def page_csvlist(articlelist,filename,content_tag) @pages = articlelist @content_tag = content_tag response.headers['Content-Type'] = 'text/csv; charset=iso-8859-1; header=present' response.headers['Content-Disposition'] = 'attachment; filename='+filename+'.csv' render(:template => 'pageinfo/page_csvlist', :layout => false) end |
- (Object) pagelinklist
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/pageinfo_controller.rb', line 42 def pagelinklist @filteredparameters = ParamsFilter.new([:content_tag,:content_types,{:onlybroken => :boolean}],params) @right_column = false if(!@filteredparameters.content_tag? or @filteredparameters.content_tag.nil?) # fake content tag for display purposes @content_tag = Tag.new(:name => 'all') else @content_tag = @filteredparameters.content_tag end # build the scope pagelist_scope = Page.scoped({}) if(@filteredparameters.content_types) content_type_conditions = Page.content_type_conditions(@filteredparameters.content_types,{:allevents => true}) if(!content_type_conditions.blank?) pagelist_scope = pagelist_scope.where(content_type_conditions) end end if(@content_tag) pagelist_scope = pagelist_scope.tagged_with_content_tag(@content_tag.name) end sort_order = "pages.has_broken_links DESC,pages.source_updated_at DESC" if(@filteredparameters.onlybroken) @pages = pagelist_scope.broken_links.paginate(:page => params[:page], :per_page => 100, :order => sort_order) else @pages = pagelist_scope.paginate(:page => params[:page], :per_page => 100, :order => sort_order) end end |
- (Object) pagelist
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'app/controllers/pageinfo_controller.rb', line 74 def pagelist @filteredparameters = ParamsFilter.new([:content_tag,:content_types,{:articlefilter => :string},{:download => :string}],params) @right_column = false if(!@filteredparameters.content_tag? or @filteredparameters.content_tag.nil?) # fake content tag for display purposes @content_tag = Tag.new(:name => 'all') else @content_tag = @filteredparameters.content_tag end @articlefilter = @filteredparameters.articlefilter if(!@filteredparameters.download.nil? and @filteredparameters.download == 'csv') isdownload = true end # build the scope pagelist_scope = Page.scoped({}) if(@filteredparameters.content_types) content_type_conditions = Page.content_type_conditions(@filteredparameters.content_types,{:allevents => true}) if(!content_type_conditions.blank?) pagelist_scope = pagelist_scope.where(content_type_conditions) end end if(@content_tag) pagelist_scope = pagelist_scope.tagged_with_content_tag(@content_tag.name) end if(!@filteredparameters.articlefilter.nil?) case @filteredparameters.articlefilter when 'all' @articlefilter = 'All' when 'feature' @articlefilter = 'Feature' bucket = 'feature' when 'learning lessons' @articlefilter = 'Learning Lesson' bucket = 'learning lessons' when 'contents' @articlefilter = 'Contents' bucket = 'contents' when 'homage' @articlefilter = 'Homage' bucket = 'homage' end # case statement if(!bucket.nil?) pagelist_scope = pagelist_scope.bucketed_as(bucket) end end # @articlefilter.nil? if(isdownload) @pages = pagelist_scope.ordered content_types = (@filteredparameters.content_types.blank?) ? 'all' : @filteredparameters.content_types.join('+') csvfilename = "#{content_types}_pages_for_tag_#{@content_tag.name}" return page_csvlist(@pages,csvfilename,@content_tag) else @pages = pagelist_scope.ordered.paginate(:page => params[:page], :per_page => 100) end end |
- (Object) show
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/pageinfo_controller.rb', line 29 def show @right_column = false @page = Page.find_by_id(params[:id]) if(@page) @external_links = @page.links.external @image_links = @page.links.image @local_links = @page.links.local @internal_links = @page.links.internal @wanted_links = @page.links.unpublished end end |