diff --git a/.ebextensions/deploy.config b/.ebextensions/deploy.config index 7aba5ca1c..244cc44ec 100644 --- a/.ebextensions/deploy.config +++ b/.ebextensions/deploy.config @@ -23,12 +23,12 @@ files: group: root content: | #!/usr/bin/env bash - wget http://download.documentfoundation.org/libreoffice/stable/5.3.6/rpm/x86_64/LibreOffice_5.3.6_Linux_x86-64_rpm.tar.gz - tar -xvzf LibreOffice_5.3.6_Linux_x86-64_rpm.tar.gz - cd LibreOffice_5.3.6.1_Linux_x86-64_rpm/RPMS + wget http://download.documentfoundation.org/libreoffice/stable/5.4.3/rpm/x86_64/LibreOffice_5.4.3_Linux_x86-64_rpm.tar.gz + tar -xvzf LibreOffice_5.4.3_Linux_x86-64_rpm.tar.gz + cd LibreOffice_5.4.3.2_Linux_x86-64_rpm/RPMS/ yum install *.rpm cd / - rm -r /tmp/LibreOffice_5.3.6_Linux_x86-64_rpm.tar.gz /tmp/LibreOffice_5.3.6.1_Linux_x86-64_rpm + rm -r /tmp/LibreOffice_5.4.3_Linux_x86-64_rpm.tar.gz /tmp/LibreOffice_5.4.3.2_Linux_x86-64_rpm "/etc/nginx/conf.d/proxy.conf" : mode: "000755" owner: root diff --git a/app/assets/javascripts/projects/show.js.coffee b/app/assets/javascripts/projects/show.js.coffee index 07347c761..0dfe268f4 100644 --- a/app/assets/javascripts/projects/show.js.coffee +++ b/app/assets/javascripts/projects/show.js.coffee @@ -65,19 +65,12 @@ IS.onReady "projects/show", -> # Takes all sessions that are checked, appends its id to the url and # redirects the user to the view sessions page (Vis page) $('#vis_button').click (e) -> - unchecked = $(document).find(".dataset .ds_selector input:not(:checked)") - unchecked_list = (get_ds_id u for u in unchecked) - # Viewing a subset of the data sets - if unchecked_list.length > 0 or window.location.href.indexOf('&search') != -1 - targets = $(document).find(".dataset .ds_selector input:checked") - ds_list = (get_ds_id t for t in targets) - # Set the value in the hidden form field - $('#visualize_selected>input').attr('value', ds_list) - # POST form - $('#visualize_selected').submit() - # Just show them all the old-fashioned way - else - window.location = $(this).attr("data-href") + targets = $(document).find(".dataset .ds_selector input:checked") + ds_list = (get_ds_id t for t in targets) + # Set the value in the hidden form field + $('#visualize_selected>input').attr('value', ds_list) + # POST form + $('#visualize_selected').submit() $('#export_button').click (e) -> $('#export_modal').modal('show') @@ -335,6 +328,13 @@ IS.onReady "projects/show", -> e.preventDefault() window.print() + ### + # Update per_page param when a drop-down option is selected + ### + $("select#display_n").change -> + window.location.href = window.location.origin + window.location.pathname + + "?per_page=#{$("#display_n option:selected").val()}" + ### # Tags ### diff --git a/app/assets/javascripts/visualizations/visualizations.js.coffee b/app/assets/javascripts/visualizations/visualizations.js.coffee index 44ed86164..fd6f353b1 100644 --- a/app/assets/javascripts/visualizations/visualizations.js.coffee +++ b/app/assets/javascripts/visualizations/visualizations.js.coffee @@ -128,11 +128,15 @@ $ -> savedConfigs = savedGlobals['globals'] savedAnnotations = savedGlobals['annotations'] $.extend(globals.configs, savedConfigs) + # Load annotations if savedAnnotations? globals.annotationSet = new AnnotationSet for elt in savedAnnotations.list annotation = $.extend(true, new Annotation, elt) globals.annotationSet.addToList annotation + # If on mobile, close sidebar + if window.innerWidth <= 600 + globals.configs.ctrlsOpen = false # Restore vis specific configs for visName in data.allVis diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 981087a37..2ef030ae5 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -267,6 +267,15 @@ body { } } +#featured_vis { + padding: 0; + + iframe { + border-radius: 10px + } +} + + #news { background: #bcd66f; background: -moz-linear-gradient(top, #bcd66f 0%, #60c600 40%, #1f9100 100%); diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 8a5b6675e..c2b42108b 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -140,3 +140,9 @@ #create_data_set { text-align: center; } + +#display_n +{ + width: 115%; + padding: 0 10 0 0; +} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 02856cef0..154aa0e24 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -62,7 +62,16 @@ def show @cloned_project = Project.select(:id, :user_id, :title).where(id: @project.cloned_from).first @liked_by_cur_user = Like.find_by_user_id_and_project_id(current_user, @project.id) - @data_sets = @project.data_sets.includes(:user).select('id', 'title', 'user_id', 'key', 'created_at', 'contributor_name').search(params[:search]) + @all_data_sets = @project.data_sets.includes(:user).select('id', 'title', 'user_id', 'key', 'created_at', 'contributor_name').search(params[:search]) + + # The comparision validates the per_page display. The minimum and maximum are arbitrarily chosen but reasonable + # Non-integer values of per_page evaluate to 0, so only valid integer values will be accepted as a param + # All other values will fail the comparison + if params[:per_page].to_i < 1 or params[:per_page].to_i > 1000 + @data_sets = @all_data_sets.paginate(page: params[:page], per_page: 100) + else + @data_sets = @all_data_sets.paginate(page: params[:page], per_page: params[:per_page]) + end @fields = @project.fields @field_count = @fields.count @formula_fields = @project.formula_fields @@ -95,7 +104,6 @@ def edit @new_contrib_key = ContribKey.new @new_contrib_key.project_id = @project.id end - # POST /projects # POST /projects.json def create @@ -687,12 +695,12 @@ def project_params :is_template, :featured_media_id, :hidden, :featured_at, :lock, :curated, :curated_at, :updated_at, :default_vis, - :precision, :globals, :kml_metadata) + :precision, :globals, :kml_metadata, :per_page) end params[:project].permit(:content, :title, :user_id, :filter, :hidden, :cloned_from, :has_fields, :featured_media_id, :lock, :updated_at, :default_vis, :precision, - :globals, :kml_metadata) + :globals, :kml_metadata, :per_page) end end diff --git a/app/models/user.rb b/app/models/user.rb index c655e1c5f..347bb826a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base include ActionView::Helpers::SanitizeHelper - validates :name, length: { minimum: 4, maximum: 70 }, format: { + validates :name, length: { minimum: 1, maximum: 70 }, format: { with: /\A[\p{Alpha}\p{Blank}\-\'\.]*\z/, message: 'can only contain letters, hyphens, single quotes, periods, and spaces.' } diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index b6f9173d3..e461680f5 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -31,7 +31,7 @@ See More Visualizations -
+