diff --git a/app/assets/javascripts/about.coffee b/app/assets/javascripts/about.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/about.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/about.scss b/app/assets/stylesheets/about.scss new file mode 100644 index 00000000..da470064 --- /dev/null +++ b/app/assets/stylesheets/about.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the About controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ \ No newline at end of file diff --git a/app/assets/stylesheets/general.scss b/app/assets/stylesheets/general.scss index b4f056a2..6b796904 100644 --- a/app/assets/stylesheets/general.scss +++ b/app/assets/stylesheets/general.scss @@ -3,8 +3,8 @@ } .main-view-container { - padding-right: 1em; - padding-left: 1em; + padding-right: .25em; + padding-left: .25em; } .inline { diff --git a/app/assets/stylesheets/header.scss b/app/assets/stylesheets/header.scss index 6c8e8009..15aff61e 100644 --- a/app/assets/stylesheets/header.scss +++ b/app/assets/stylesheets/header.scss @@ -9,12 +9,16 @@ } .version { - font-size: 55%; + font-size: 60%; } #verticals-nav { display: inline-block; + a { + font-size: 16px; + } + ul { vertical-align: top; display: inline-block; diff --git a/app/assets/stylesheets/vertical.scss b/app/assets/stylesheets/vertical.scss index 6e13532d..724ea2c6 100644 --- a/app/assets/stylesheets/vertical.scss +++ b/app/assets/stylesheets/vertical.scss @@ -80,7 +80,8 @@ li .snippet { margin-top: 1em; } -.tag-badge { + +.tag-badge-0 { font-size: 85%; border-radius: 2em; background-color: lighten($brand-primary, 0%); @@ -88,6 +89,7 @@ li .snippet { padding-left: .5em; padding-right: .5em; color: white; + background-color: red; a, a:active, a:hover, a:visited { color: white; } @@ -97,6 +99,132 @@ li .snippet { } } +.tag-badge-1 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: black; + background-color: cyan; + a, a:active, a:hover, a:visited { + color: black; + } + + .edit:hover, .delete:hover { + color: #ccc; + } +} + +.tag-badge-2 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: white; + background-color: green; + a, a:active, a:hover, a:visited { + color: white; + } + + .edit:hover, .delete:hover { + color: #ccc; + } +} + .tag-badge-3 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: white; + background-color: blue; + a, a:active, a:hover, a:visited { + color: white; + } + + .edit:hover, .delete:hover { + color: #ccc; + } + } + + .tag-badge-4 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: white; + background-color: brown; + a, a:active, a:hover, a:visited { + color: white; + } + + .edit:hover, .delete:hover { + color: #ccc; + } + } + + .tag-badge-5 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: white; + background-color: black; + a, a:active, a:hover, a:visited { + color: white; + } + + .edit:hover, .delete:hover { + color: #ccc; + } + } + + .tag-badge-6 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: black; + background-color: skyblue; + a, a:active, a:hover, a:visited { + color: black; + } + + .edit:hover, .delete:hover { + color: red; + } + } + + .tag-badge-7 { + font-size: 85%; + border-radius: 2em; + background-color: lighten($brand-primary, 0%); + display: inline-block; + padding-left: .5em; + padding-right: .5em; + color: black; + background-color: grey; + a, a:active, a:hover, a:visited { + color: black; + } + + .edit:hover, .delete:hover { + color: red; + } + } + + span.tag-title, span.summary-title { font-weight: bold; } @@ -326,6 +454,7 @@ ul.authors, ul.instructors { .vertical-index .assignment_group.index-entry { height: 500px; + border: 20px, solid, #0000; .item-content { height: 275px; } @@ -362,12 +491,13 @@ ul.authors, ul.instructors { .analysis-page, .software-page, .dataset-page, .example-page { - + background-color: #d3d3d3; .thumbnail-wrapper.show-view { - margin-top: 20px; + margin-top: 50px; background-size: cover; background-position-x: 50%; background-position-y: center; + border: 5px solid #45b6fe; height: 175px; @@ -375,8 +505,6 @@ ul.authors, ul.instructors { display: block; overflow: hidden; - // border-bottom: 1px solid #ccc; - img { width: 100%; } @@ -384,11 +512,13 @@ ul.authors, ul.instructors { } .assignment-page { + background-color: #d3d3d3; .thumbnail-wrapper.show-view { - //margin-top: 20px; + margin-bottom: 20px; background-size: cover; background-position-x: 50%; background-position-y: center; + border: 5px solid #45b6fe; height: 175px; diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb new file mode 100644 index 00000000..de76684e --- /dev/null +++ b/app/controllers/about_controller.rb @@ -0,0 +1,5 @@ +class AboutController < ApplicationController + def index + about_path + end +end diff --git a/app/controllers/analyses_controller.rb b/app/controllers/analyses_controller.rb index 5658f54c..dc5b6c6f 100644 --- a/app/controllers/analyses_controller.rb +++ b/app/controllers/analyses_controller.rb @@ -8,17 +8,26 @@ class AnalysesController < ApplicationController before_action :get_redirect_path def index - @analyses = Analysis.all.sort_by { |e| e.name } + @analyses = Analysis.where({creator: current_user}).or(Analysis.where({is_draft: false})).sort_by { |e| e.name } end def connect_index - @analyses = Analysis.all.sort_by { |e| e.name } + @analyses = Analysis.where({creator: current_user}).or(Analysis.where({is_draft: false})).sort_by { |e| e.name } if @vertical.class == Analysis @analyses.delete(@vertical) end end def show + if (@analysis.is_draft and @analysis.creator != current_user) + error = "You are unauthorised to view this assignment." + respond_to do |format| + format.json {render json: {success: false, error: error}} + format.html do + render file: "#{Rails.root}/public/404.html" , status: 404 + end + end + end end def new @@ -30,9 +39,15 @@ def edit ## Creates a new analysis entry. def create + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Analysis created successfully!" + else + @data[:is_draft] = true + @success_message = "Analysis saved as draft!" + end @data[:creator] = current_user @analysis = Analysis.new(@data) - # ## Make sure we have the required fields. # if get_with_default(@data, :name, "").empty? or # get_with_default(@data, :summary, "").empty? or @@ -60,9 +75,17 @@ def create ## and deleted altogether if the resource isn't associated with another ## vertical entry. def update + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Analysis created successfully!" + else + @data[:is_draft] = true + @success_message = "Analysis saved as draft!" + end + begin ActiveRecord::Base.transaction do - @analysis.update(@data.permit(:name, :description, :summary, :thumbnail)) + @analysis.update(@data.permit(:name, :description, :summary, :thumbnail, :is_draft)) @analysis.save! @analysis.reindex_associations diff --git a/app/controllers/assignment_groups_controller.rb b/app/controllers/assignment_groups_controller.rb index 49a4f0be..3697398b 100644 --- a/app/controllers/assignment_groups_controller.rb +++ b/app/controllers/assignment_groups_controller.rb @@ -9,21 +9,31 @@ class AssignmentGroupsController < ApplicationController before_action :get_redirect_path def index - @assignment_groups = AssignmentGroup.all.sort_by { |e| e.name } + @assignment_groups = AssignmentGroup.where({creator: current_user}).or(AssignmentGroup.where({is_draft: false})).sort_by { |e| e.name } end def connect_index - @assignment_groups = AssignmentGroup.all.sort_by { |e| e.name } + @assignment_groups = AssignmentGroup.where({creator: current_user}).or(AssignmentGroup.where({is_draft: false})).sort_by { |e| e.name } if @vertical.class == AssignmentGroup @assignment_groups.delete(@vertical) end end def show + if (@assignment_group.is_draft and @assignment_group.creator != current_user) + error = "You are unauthorised to view this assignment." + respond_to do |format| + format.json {render json: {success: false, error: error}} + format.html do + render file: "#{Rails.root}/public/404.html" , status: 404 + end + end + end end def new @assignment_group = AssignmentGroup.new + # respond_with_success get_redirect_path(@assignment_group) end def edit @@ -32,37 +42,28 @@ def edit ## Creates a new assignment_group entry. def create - - # ## Make sure we have the required fields. - # if get_with_default(@data, :name, "").empty? or - # get_with_default(@data, :summary, "").empty? or - # @authors.empty? - - # # respond_with_error "You must provide a name, summary, and at least one author.", - # # new_assignment_group_path - # @data[:authors] = @authors - # @assignment_group = AssignmentGroup.new(@data) - - # respond_with_error "You must provide a name, summary, and at least one author.", - # 'new', true, false - # return - # end - - ## Create the new entry. - @data[:creator] = current_user - @data[:authors] = @authors - @assignment_group = AssignmentGroup.new(@data) - begin - ActiveRecord::Base.transaction do - @assignment_group.save! - flash[:success] = "Assignment created successfully!" - respond_with_success get_redirect_path(assignment_group_path(@assignment_group)) - end - rescue => e - # puts "#{@author_ids} #{e.message} #{e.backtrace.join("\n")}" - respond_with_error "There was an error saving the assignment group entry: #{e}", - 'new', true, false + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Assignment created successfully!" + else + @data[:is_draft] = true + @success_message = "Assignment saved as draft!" end + @data[:creator] = current_user + @data[:authors] = @authors + + @assignment_group = AssignmentGroup.new(@data) + begin + ActiveRecord::Base.transaction do + @assignment_group.save! + flash[:success] = @success_message + respond_with_success get_redirect_path(assignment_group_path(@assignment_group)) + end + rescue => e + # puts "#{@author_ids} #{e.message} #{e.backtrace.join("\n")}" + respond_with_error "There was an error saving the assignment group entry: #{e}", + 'new', true, false + end end ## Updates a assignment_group entry. Takes all the usual parameters. The tags @@ -71,7 +72,14 @@ def create ## and deleted altogether if the resource isn't associated with another ## vertical entry. def update - + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Assignment created successfully!" + else + @data[:is_draft] = true + @success_message = "Assignment saved as draft!" + end + begin ActiveRecord::Base.transaction do @data[:authors] = @authors if params.require(:assignment_group).has_key?(:authors) @@ -119,7 +127,7 @@ def get_response_format def get_params begin @data = params.require(:assignment_group).permit( - :name, :summary, :description, :thumbnail + :name, :summary, :description, :thumbnail, :button_press ) @author_ids = get_with_default( params.require(:assignment_group).permit(:authors), :authors, "") diff --git a/app/controllers/datasets_controller.rb b/app/controllers/datasets_controller.rb index c21ade8e..4c9c510b 100644 --- a/app/controllers/datasets_controller.rb +++ b/app/controllers/datasets_controller.rb @@ -8,17 +8,26 @@ class DatasetsController < ApplicationController before_action :get_redirect_path def index - @datasets = Dataset.all.sort_by { |e| e.name } + @datasets = Dataset.where({creator: current_user}).or(Dataset.where({is_draft: false})).sort_by { |e| e.name } end def connect_index - @datasets = Dataset.all.sort_by { |e| e.name } + @datasets = Dataset.where({creator: current_user}).or(Dataset.where({is_draft: false})).sort_by { |e| e.name } if @vertical.class == Dataset @datasets.delete(@vertical) end end def show + if (@dataset.is_draft and @dataset.creator != current_user) + error = "You are unauthorised to view this assignment." + respond_to do |format| + format.json {render json: {success: false, error: error}} + format.html do + render file: "#{Rails.root}/public/404.html" , status: 404 + end + end + end end def new @@ -42,6 +51,13 @@ def create ## Create the new entry. @data[:creator] = current_user + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Dataset created successfully!" + else + @data[:is_draft] = true + @success_message = "Dataset saved as draft!" + end @dataset = Dataset.new(@data) begin ActiveRecord::Base.transaction do @@ -60,9 +76,16 @@ def create ## and deleted altogether if the resource isn't associated with another ## vertical entry. def update + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Draft published!" + else + @data[:is_draft] = true + @success_message = "Draft updated!" + end begin ActiveRecord::Base.transaction do - @dataset.update(@data.permit(:name, :description, :summary, :thumbnail)) + @dataset.update(@data.permit(:name, :description, :summary, :thumbnail, :is_draft)) @dataset.save! @dataset.reindex_associations diff --git a/app/controllers/examples_controller.rb b/app/controllers/examples_controller.rb index fdd8d4b3..94f59ced 100644 --- a/app/controllers/examples_controller.rb +++ b/app/controllers/examples_controller.rb @@ -8,6 +8,15 @@ class ExamplesController < ApplicationController before_action :get_redirect_path def show + if (@example.is_draft and @example.creator != current_user) + error = "You are unauthorised to view this assignment." + respond_to do |format| + format.json {render json: {success: false, error: error}} + format.html do + render file: "#{Rails.root}/public/404.html" , status: 404 + end + end + end end def new @@ -17,11 +26,11 @@ def edit end def index - @examples = Example.all.sort_by{|e| e.title} + @examples = Example.where({creator: current_user}).or(Example.where({is_draft: false})).sort_by { |e| e.title } end def connect_index - @examples = Example.all.sort_by { |e| e.title } + @examples = Example.where({creator: current_user}).or(Example.where({is_draft: false})).sort_by { |e| e.title } if @vertical.class == Example @examples.delete(@vertical) end @@ -29,6 +38,14 @@ def connect_index def create @params[:creator] = current_user + if params[:button_press] == "Save" + @params[:is_draft] = false + @success_message = "Dataset created successfully!" + else + @params[:is_draft] = true + @success_message = "Dataset saved as draft!" + end + @example = Example.new(@params) begin # if @params[:summary].nil? or @params[:summary].size == 0 @@ -49,7 +66,14 @@ def create end def update - + if params[:button_press] == "Save" + @params[:is_draft] = false + @success_message = "Dataset created successfully!" + else + @params[:is_draft] = true + @success_message = "Dataset saved as draft!" + end + begin @example.update! @params @example.reindex_associations diff --git a/app/controllers/homepage_controller.rb b/app/controllers/homepage_controller.rb index 44afdd07..dfc6ac5a 100644 --- a/app/controllers/homepage_controller.rb +++ b/app/controllers/homepage_controller.rb @@ -1,9 +1,9 @@ class HomepageController < ApplicationController def show - @analyses = Analysis.last(9).reverse - @assignment_groups = AssignmentGroup.last(9).reverse - @datasets = Dataset.last(9).reverse - @examples = Example.last(9).reverse - @software = Software.last(9).reverse + @analyses = Analysis.where({creator: current_user}).or(Analysis.where({is_draft: false})).last(9).reverse + @assignment_groups = AssignmentGroup.where({creator: current_user}).or(AssignmentGroup.where({is_draft: false})).last(9).reverse + @datasets = Dataset.where({creator: current_user}).or(Dataset.where({is_draft: false})).last(9).reverse + @examples = Example.where({creator: current_user}).or(Example.where({is_draft: false})).last(9).reverse + @software = Software.where({creator: current_user}).or(Software.where({is_draft: false})).last(9).reverse end end diff --git a/app/controllers/software_controller.rb b/app/controllers/software_controller.rb index 88262550..8371c39a 100644 --- a/app/controllers/software_controller.rb +++ b/app/controllers/software_controller.rb @@ -8,17 +8,26 @@ class SoftwareController < ApplicationController before_action :get_redirect_path def index - @software = Software.all.sort_by { |e| e.name } + @software = Software.where({creator: current_user}).or(Software.where({is_draft: false})).sort_by { |e| e.name } end def connect_index - @software = Software.all.sort_by { |e| e.name } + @softwares = Software.where({creator: current_user}).or(Software.where({is_draft: false})).sort_by { |e| e.name } if @vertical.class == Software @software.delete(@vertical) end end def show + if (@software.is_draft and @software.creator != current_user) + error = "You are unauthorised to view this assignment." + respond_to do |format| + format.json {render json: {success: false, error: error}} + format.html do + render file: "#{Rails.root}/public/404.html" , status: 404 + end + end + end end def new @@ -42,6 +51,13 @@ def create ## Create the new entry. @data[:creator] = current_user + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Software created successfully!" + else + @data[:is_draft] = true + @success_message = "Software saved as draft!" + end @software = Software.new(@data) begin ActiveRecord::Base.transaction do @@ -60,9 +76,17 @@ def create ## and deleted altogether if the resource isn't associated with another ## vertical entry. def update + if params[:button_press] == "Save" + @data[:is_draft] = false + @success_message = "Software created successfully!" + else + @data[:is_draft] = true + @success_message = "Software saved as draft!" + end + begin ActiveRecord::Base.transaction do - @software.update!(@data.permit(:name, :description, :summary, :thumbnail)) + @software.update!(@data.permit(:name, :description, :summary, :thumbnail, :is_draft)) @software.reindex_associations respond_with_success get_redirect_path(software_path(@software)) diff --git a/app/helpers/about_helper.rb b/app/helpers/about_helper.rb new file mode 100644 index 00000000..68e69aee --- /dev/null +++ b/app/helpers/about_helper.rb @@ -0,0 +1,2 @@ +module AboutHelper +end diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb new file mode 100644 index 00000000..8d6236c7 --- /dev/null +++ b/app/views/about/index.html.erb @@ -0,0 +1,24 @@ +

About Alice

+

Alice is a database of tools (and other things) for the digital liberal arts.

+

Purpose

+

The goal of the Alice database is to provide a system for curating information regarding tools and their application in the digital liberal arts. It allows the tracking of the following verticals: + +analyses/methods (e.g., network diagramming) +software tools (e.g., NodeXL) +datasets (e.g., a set of labeled Tweets) +projects (e.g., performing network analysis using NodeXL over labeled Tweets) +Storing this data is only part of Alice's goal. The mission critical functionality includes: + +easily searchable, including advanced search operations +easily browsable for casual discovery +With these verticals and information discovery goals met, users can find and share tools, methods, datasets, and examples of how to use them.

+ +

Contributers

+

+