diff --git a/Gemfile.lock b/Gemfile.lock index efec0f57..3346fa26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,31 +29,31 @@ GEM i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) arel (3.0.3) - bcrypt-ruby (3.0.1) - bcrypt-ruby (3.0.1-x86-mingw32) - best_in_place (2.0.2) + bcrypt (3.1.7) + bcrypt (3.1.7-x86-mingw32) + best_in_place (2.1.0) jquery-rails rails (~> 3.1) builder (3.0.4) - cancan (1.6.7) + cancan (1.6.10) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.3.3) - devise (2.2.3) - bcrypt-ruby (~> 3.0) + coffee-script-source (1.7.0) + devise (3.2.4) + bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (~> 3.1) - warden (~> 1.2.1) + railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) + warden (~> 1.2.3) erubis (2.7.0) - execjs (1.4.0) - multi_json (~> 1.0) - formtastic (2.0.2) - rails (~> 3.0) - formula (0.3.3) + execjs (2.0.2) + formtastic (2.2.1) + actionpack (>= 3.0) + formula (1.0.1) rails (> 3.0.0) hike (1.2.3) i18n (0.6.9) @@ -68,10 +68,10 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) - multi_json (1.9.3) - orm_adapter (0.4.0) - pg (0.12.2) - pg (0.12.2-x86-mingw32) + multi_json (1.10.0) + orm_adapter (0.5.0) + pg (0.17.1) + pg (0.17.1-x86-mingw32) polyglot (0.3.4) rack (1.4.5) rack-cache (1.2) @@ -88,8 +88,8 @@ GEM activesupport (= 3.2.17) bundler (~> 1.0) railties (= 3.2.17) - rails3-jquery-autocomplete (1.0.10) - rails (~> 3.0) + rails3-jquery-autocomplete (1.0.14) + rails (>= 3.0) railties (3.2.17) actionpack (= 3.2.17) activesupport (= 3.2.17) @@ -97,13 +97,13 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (10.3.1) + rake (10.3.2) rdoc (3.12.2) json (~> 1.4) - redis (2.2.2) - sass (3.2.7) - sass-rails (3.2.3) - railties (~> 3.2.0.beta) + redis (3.0.7) + sass (3.3.7) + sass-rails (3.2.6) + railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) sprockets (2.2.2) @@ -112,15 +112,16 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) tzinfo (0.3.39) - uglifier (1.3.0) + uglifier (2.5.0) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - warden (1.2.1) + json (>= 1.8.0) + warden (1.2.3) rack (>= 1.0) PLATFORMS diff --git a/app/assets/images/action.png b/app/assets/images/icons/action.png similarity index 100% rename from app/assets/images/action.png rename to app/assets/images/icons/action.png diff --git a/app/assets/images/activity.png b/app/assets/images/icons/activity.png similarity index 100% rename from app/assets/images/activity.png rename to app/assets/images/icons/activity.png diff --git a/app/assets/images/argument.png b/app/assets/images/icons/argument.png similarity index 100% rename from app/assets/images/argument.png rename to app/assets/images/icons/argument.png diff --git a/app/assets/images/bizarre.png b/app/assets/images/icons/bizarre.png similarity index 100% rename from app/assets/images/bizarre.png rename to app/assets/images/icons/bizarre.png diff --git a/app/assets/images/catalyst.png b/app/assets/images/icons/catalyst.png similarity index 100% rename from app/assets/images/catalyst.png rename to app/assets/images/icons/catalyst.png diff --git a/app/assets/images/closed.png b/app/assets/images/icons/closed.png similarity index 100% rename from app/assets/images/closed.png rename to app/assets/images/icons/closed.png diff --git a/app/assets/images/con_icon.png b/app/assets/images/icons/con_icon.png similarity index 100% rename from app/assets/images/con_icon.png rename to app/assets/images/icons/con_icon.png diff --git a/app/assets/images/decision.png b/app/assets/images/icons/decision.png similarity index 100% rename from app/assets/images/decision.png rename to app/assets/images/icons/decision.png diff --git a/app/assets/images/example.png b/app/assets/images/icons/example.png similarity index 100% rename from app/assets/images/example.png rename to app/assets/images/icons/example.png diff --git a/app/assets/images/experience.png b/app/assets/images/icons/experience.png similarity index 100% rename from app/assets/images/experience.png rename to app/assets/images/icons/experience.png diff --git a/app/assets/images/foresight.png b/app/assets/images/icons/foresight.png similarity index 100% rename from app/assets/images/foresight.png rename to app/assets/images/icons/foresight.png diff --git a/app/assets/images/futuredev.png b/app/assets/images/icons/futuredev.png similarity index 100% rename from app/assets/images/futuredev.png rename to app/assets/images/icons/futuredev.png diff --git a/app/assets/images/goodpractice.png b/app/assets/images/icons/goodpractice.png similarity index 100% rename from app/assets/images/goodpractice.png rename to app/assets/images/icons/goodpractice.png diff --git a/app/assets/images/group.png b/app/assets/images/icons/group.png similarity index 100% rename from app/assets/images/group.png rename to app/assets/images/icons/group.png diff --git a/app/assets/images/idea.png b/app/assets/images/icons/idea.png similarity index 100% rename from app/assets/images/idea.png rename to app/assets/images/icons/idea.png diff --git a/app/assets/images/implication.png b/app/assets/images/icons/implication.png similarity index 100% rename from app/assets/images/implication.png rename to app/assets/images/icons/implication.png diff --git a/app/assets/images/insight.png b/app/assets/images/icons/insight.png similarity index 100% rename from app/assets/images/insight.png rename to app/assets/images/icons/insight.png diff --git a/app/assets/images/intention.png b/app/assets/images/icons/intention.png similarity index 100% rename from app/assets/images/intention.png rename to app/assets/images/icons/intention.png diff --git a/app/assets/images/knowledge.png b/app/assets/images/icons/knowledge.png similarity index 100% rename from app/assets/images/knowledge.png rename to app/assets/images/icons/knowledge.png diff --git a/app/assets/images/list.png b/app/assets/images/icons/list.png similarity index 100% rename from app/assets/images/list.png rename to app/assets/images/icons/list.png diff --git a/app/assets/images/location.png b/app/assets/images/icons/location.png similarity index 100% rename from app/assets/images/location.png rename to app/assets/images/icons/location.png diff --git a/app/assets/images/moviemap.png b/app/assets/images/icons/moviemap.png similarity index 100% rename from app/assets/images/moviemap.png rename to app/assets/images/icons/moviemap.png diff --git a/app/assets/images/note.png b/app/assets/images/icons/note.png similarity index 100% rename from app/assets/images/note.png rename to app/assets/images/icons/note.png diff --git a/app/assets/images/openissue.png b/app/assets/images/icons/openissue.png similarity index 100% rename from app/assets/images/openissue.png rename to app/assets/images/icons/openissue.png diff --git a/app/assets/images/opinion.png b/app/assets/images/icons/opinion.png similarity index 100% rename from app/assets/images/opinion.png rename to app/assets/images/icons/opinion.png diff --git a/app/assets/images/opportunity.png b/app/assets/images/icons/opportunity.png similarity index 100% rename from app/assets/images/opportunity.png rename to app/assets/images/icons/opportunity.png diff --git a/app/assets/images/person.png b/app/assets/images/icons/person.png similarity index 100% rename from app/assets/images/person.png rename to app/assets/images/icons/person.png diff --git a/app/assets/images/platform.png b/app/assets/images/icons/platform.png similarity index 100% rename from app/assets/images/platform.png rename to app/assets/images/icons/platform.png diff --git a/app/assets/images/pro.png b/app/assets/images/icons/pro.png similarity index 100% rename from app/assets/images/pro.png rename to app/assets/images/icons/pro.png diff --git a/app/assets/images/problem.png b/app/assets/images/icons/problem.png similarity index 100% rename from app/assets/images/problem.png rename to app/assets/images/icons/problem.png diff --git a/app/assets/images/question.png b/app/assets/images/icons/question.png similarity index 100% rename from app/assets/images/question.png rename to app/assets/images/icons/question.png diff --git a/app/assets/images/reference.png b/app/assets/images/icons/reference.png similarity index 100% rename from app/assets/images/reference.png rename to app/assets/images/icons/reference.png diff --git a/app/assets/images/requirement.png b/app/assets/images/icons/requirement.png similarity index 100% rename from app/assets/images/requirement.png rename to app/assets/images/icons/requirement.png diff --git a/app/assets/images/research.png b/app/assets/images/icons/research.png similarity index 100% rename from app/assets/images/research.png rename to app/assets/images/icons/research.png diff --git a/app/assets/images/resource.png b/app/assets/images/icons/resource.png similarity index 100% rename from app/assets/images/resource.png rename to app/assets/images/icons/resource.png diff --git a/app/assets/images/role.png b/app/assets/images/icons/role.png similarity index 100% rename from app/assets/images/role.png rename to app/assets/images/icons/role.png diff --git a/app/assets/images/task.png b/app/assets/images/icons/task.png similarity index 100% rename from app/assets/images/task.png rename to app/assets/images/icons/task.png diff --git a/app/assets/images/tool.png b/app/assets/images/icons/tool.png similarity index 100% rename from app/assets/images/tool.png rename to app/assets/images/icons/tool.png diff --git a/app/assets/images/trajectory.png b/app/assets/images/icons/trajectory.png similarity index 100% rename from app/assets/images/trajectory.png rename to app/assets/images/icons/trajectory.png diff --git a/app/assets/images/wildcard.png b/app/assets/images/icons/wildcard.png similarity index 100% rename from app/assets/images/wildcard.png rename to app/assets/images/icons/wildcard.png diff --git a/app/assets/images/junto.png b/app/assets/images/junto.png deleted file mode 100644 index 2dd623b5..00000000 Binary files a/app/assets/images/junto.png and /dev/null differ diff --git a/app/assets/javascripts/in_metacode_sets.js.coffee b/app/assets/javascripts/in_metacode_sets.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/in_metacode_sets.js.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://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/metacode_sets.js.coffee b/app/assets/javascripts/metacode_sets.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/metacode_sets.js.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://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f935363e..c9246c6f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1998,7 +1998,124 @@ font-weight: bold; } +/* Admin Pages */ +#wrapper > div.blackBox { +width: 700px; +margin: 0 auto; +padding: 20px 0 20px 20px; +background: rgba(0,0,0,0.4); +color: white; +height: 100%; +overflow: hidden; +position: relative; +} + +.blackBox .metacodeSetsDescription { + width: 340px; +} + +.blackBox tr:nth-child(odd) { + background: rgba(0, 0, 0, 0.2); +} +.blackBox tr:nth-child(even) { + background: rgba(0, 0, 0, 0.3); +} + +.blackBox th, .blackBox td { + padding:10px; +} + +.blackBox .field { + margin: 15px 0 5px; +} + +.blackBox label { + float:left; + width: 100px; + margin-right: 15px; +} + +.blackBox input[type="text"] { +width: 336px; +height: 32px; +font-size: 15px; +direction: ltr; +-webkit-appearance: none; +appearance: none; +display: inline-block; +margin: 0; +padding: 0 8px; +background: #fff; +border: 1px solid #d9d9d9; +border-top: 1px solid #c0c0c0; +-webkit-box-sizing: border-box; +-moz-box-sizing: border-box; +box-sizing: border-box; +-webkit-border-radius: 1px; +-moz-border-radius: 1px; +border-radius: 1px; +font: -webkit-small-control; +color: initial; +letter-spacing: normal; +word-spacing: normal; +text-transform: none; +text-indent: 0px; +text-shadow: none; +display: inline-block; +text-align: start; +font-family:arial; +} +.blackBox input[type="text"]:hover, .blackBox textarea:hover { + border: 1px solid #b9b9b9; + border-top: 1px solid #a0a0a0; + -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); + -moz-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); + box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); +} + +.blackBox textarea { + padding:8px; + border: 1px solid #d9d9d9; + border-top: 1px solid #c0c0c0; + resize:none; + font: -webkit-small-control; + letter-spacing: normal; + word-spacing: normal; + text-transform: none; + text-indent: 0px; + text-shadow: none; + text-align: start; + font-family:arial; + font-size:15px; + line-height:17px; + width:318px; +} + +.blackBox .allMetacodes { + padding:5px 0; +} + +.blackBox a.button { + margin-right: 20px; + line-height: 40px; +} + +.blackBox a.button, .blackBox input.add { + float: left; + margin-top: 5px; + height: 40px; + font-family: 'LatoItalic'; + font-size: 17px; + width: auto; + padding: 0 30px; + cursor:pointer; + font-weight:normal; +} +.blackBox a.button:hover, .blackBox input.add:hover { + -webkit-box-shadow: none; + box-shadow: none; +} /* FAQ */ diff --git a/app/assets/stylesheets/in_metacode_sets.css.scss b/app/assets/stylesheets/in_metacode_sets.css.scss new file mode 100644 index 00000000..9bf15655 --- /dev/null +++ b/app/assets/stylesheets/in_metacode_sets.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the InMetacodeSets controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/metacode_sets.css.scss b/app/assets/stylesheets/metacode_sets.css.scss new file mode 100644 index 00000000..a23f1f68 --- /dev/null +++ b/app/assets/stylesheets/metacode_sets.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the MetacodeSets controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef25a477..a29a2360 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base helper_method :user helper_method :authenticated? + helper_method :admin? after_filter :store_location @@ -33,6 +34,13 @@ private return false end end + + def require_admin + unless authenticated? && user.admin + redirect_to root_url, notice: "You need to be an admin for that." + return false + end + end def user current_user @@ -42,5 +50,9 @@ private def authenticated? current_user end + + def admin? + current_user && current_user.admin + end end diff --git a/app/controllers/in_metacode_sets_controller.rb b/app/controllers/in_metacode_sets_controller.rb new file mode 100644 index 00000000..36a262ff --- /dev/null +++ b/app/controllers/in_metacode_sets_controller.rb @@ -0,0 +1,86 @@ +class InMetacodeSetsController < ApplicationController + + before_filter :require_admin + + # GET /in_metacode_sets + # GET /in_metacode_sets.json + def index + @in_metacode_sets = InMetacodeSet.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @in_metacode_sets } + end + end + + # GET /in_metacode_sets/1 + # GET /in_metacode_sets/1.json + def show + @in_metacode_set = InMetacodeSet.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @in_metacode_set } + end + end + + # GET /in_metacode_sets/new + # GET /in_metacode_sets/new.json + def new + @in_metacode_set = InMetacodeSet.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @in_metacode_set } + end + end + + # GET /in_metacode_sets/1/edit + def edit + @in_metacode_set = InMetacodeSet.find(params[:id]) + end + + # POST /in_metacode_sets + # POST /in_metacode_sets.json + def create + @in_metacode_set = InMetacodeSet.new(params[:in_metacode_set]) + + respond_to do |format| + if @in_metacode_set.save + format.html { redirect_to @in_metacode_set, notice: 'In metacode set was successfully created.' } + format.json { render json: @in_metacode_set, status: :created, location: @in_metacode_set } + else + format.html { render action: "new" } + format.json { render json: @in_metacode_set.errors, status: :unprocessable_entity } + end + end + end + + # PUT /in_metacode_sets/1 + # PUT /in_metacode_sets/1.json + def update + @in_metacode_set = InMetacodeSet.find(params[:id]) + + respond_to do |format| + if @in_metacode_set.update_attributes(params[:in_metacode_set]) + format.html { redirect_to @in_metacode_set, notice: 'In metacode set was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @in_metacode_set.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /in_metacode_sets/1 + # DELETE /in_metacode_sets/1.json + def destroy + @in_metacode_set = InMetacodeSet.find(params[:id]) + @in_metacode_set.destroy + + respond_to do |format| + format.html { redirect_to in_metacode_sets_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/metacode_sets_controller.rb b/app/controllers/metacode_sets_controller.rb new file mode 100644 index 00000000..9e16ae83 --- /dev/null +++ b/app/controllers/metacode_sets_controller.rb @@ -0,0 +1,119 @@ +class MetacodeSetsController < ApplicationController + + before_filter :require_admin + + # GET /metacode_sets + # GET /metacode_sets.json + def index + @metacode_sets = MetacodeSet.order("name").all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @metacode_sets } + end + end + + ### SHOW IS NOT CURRENTLY IN USE + # GET /metacode_sets/1 + # GET /metacode_sets/1.json + def show + @metacode_set = MetacodeSet.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @metacode_set } + end + end + + # GET /metacode_sets/new + # GET /metacode_sets/new.json + def new + @metacode_set = MetacodeSet.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @metacode_set } + end + end + + # GET /metacode_sets/1/edit + def edit + @metacode_set = MetacodeSet.find(params[:id]) + end + + # POST /metacode_sets + # POST /metacode_sets.json + def create + @user = current_user + @metacode_set = MetacodeSet.new(params[:metacode_set]) + @metacode_set.user_id = @user.id + + respond_to do |format| + if @metacode_set.save + # create the InMetacodeSet for all the metacodes that were selected for the set + @metacodes = params[:metacodes][:value].split(',') + @metacodes.each do |m| + InMetacodeSet.create(:metacode_id => m, :metacode_set_id => @metacode_set.id) + end + format.html { redirect_to metacode_sets_url, notice: 'Metacode set was successfully created.' } + format.json { render json: @metacode_set, status: :created, location: metacode_sets_url } + else + format.html { render action: "new" } + format.json { render json: @metacode_set.errors, status: :unprocessable_entity } + end + end + end + + # PUT /metacode_sets/1 + # PUT /metacode_sets/1.json + def update + @metacode_set = MetacodeSet.find(params[:id]) + + respond_to do |format| + if @metacode_set.update_attributes(params[:metacode_set]) + + # build an array of the IDs of the metacodes currently in the set + @currentMetacodes = @metacode_set.metacodes.map{ |m| m.id.to_s } + # get the list of desired metacodes for the set from the user input and build an array out of it + @newMetacodes = params[:metacodes][:value].split(',') + + #remove the metacodes that were in it, but now aren't + @removedMetacodes = @currentMetacodes - @newMetacodes + @removedMetacodes.each do |m| + @inmetacodeset = InMetacodeSet.find_by_metacode_id_and_metacode_set_id(m, @metacode_set.id) + @inmetacodeset.destroy + end + + # add the new metacodes + @addedMetacodes = @newMetacodes - @currentMetacodes + @addedMetacodes.each do |m| + InMetacodeSet.create(:metacode_id => m, :metacode_set_id => @metacode_set.id) + end + + format.html { redirect_to metacode_sets_url, notice: 'Metacode set was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @metacode_set.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /metacode_sets/1 + # DELETE /metacode_sets/1.json + def destroy + @metacode_set = MetacodeSet.find(params[:id]) + + #delete everything that tracks what's in the set + @metacode_set.in_metacode_sets.each do |m| + m.destroy + end + + @metacode_set.destroy + + respond_to do |format| + format.html { redirect_to metacode_sets_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/metacodes_controller.rb b/app/controllers/metacodes_controller.rb new file mode 100644 index 00000000..0f39b076 --- /dev/null +++ b/app/controllers/metacodes_controller.rb @@ -0,0 +1,89 @@ +class MetacodesController < ApplicationController + + before_filter :require_admin + + # GET /metacodes + # GET /metacodes.json + def index + @metacodes = Metacode.order("name").all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @metacodes } + end + end + + ### SHOW IS CURRENTLY DISABLED + # GET /metacodes/1 + # GET /metacodes/1.json + def show + @metacode = Metacode.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @metacode } + end + end + + # GET /metacodes/new + # GET /metacodes/new.json + def new + @metacode = Metacode.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @metacode } + end + end + + # GET /metacodes/1/edit + def edit + @metacode = Metacode.find(params[:id]) + end + + # POST /metacodes + # POST /metacodes.json + def create + @metacode = Metacode.new(params[:metacode]) + + respond_to do |format| + if @metacode.save + format.html { redirect_to metacodes_url, notice: 'Metacode was successfully created.' } + format.json { render json: @metacode, status: :created, location: metacodes_url } + else + format.html { render action: "new" } + format.json { render json: @metacode.errors, status: :unprocessable_entity } + end + end + end + + # PUT /metacodes/1 + # PUT /metacodes/1.json + def update + @metacode = Metacode.find(params[:id]) + + respond_to do |format| + if @metacode.update_attributes(params[:metacode]) + format.html { redirect_to metacodes_url, notice: 'Metacode was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @metacode.errors, status: :unprocessable_entity } + end + end + end + + + ### DESTROY IS CURRENTLY DISABLED + # DELETE /metacodes/1 + # DELETE /metacodes/1.json + def destroy + @metacode = Metacode.find(params[:id]) + @metacode.destroy + + respond_to do |format| + format.html { redirect_to metacodes_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/in_metacode_sets_helper.rb b/app/helpers/in_metacode_sets_helper.rb new file mode 100644 index 00000000..52a47cdc --- /dev/null +++ b/app/helpers/in_metacode_sets_helper.rb @@ -0,0 +1,2 @@ +module InMetacodeSetsHelper +end diff --git a/app/helpers/metacode_sets_helper.rb b/app/helpers/metacode_sets_helper.rb new file mode 100644 index 00000000..668ceb5c --- /dev/null +++ b/app/helpers/metacode_sets_helper.rb @@ -0,0 +1,2 @@ +module MetacodeSetsHelper +end diff --git a/app/helpers/metacodes_helper.rb b/app/helpers/metacodes_helper.rb new file mode 100644 index 00000000..c896d26d --- /dev/null +++ b/app/helpers/metacodes_helper.rb @@ -0,0 +1,2 @@ +module MetacodesHelper +end diff --git a/app/models/in_metacode_set.rb b/app/models/in_metacode_set.rb new file mode 100644 index 00000000..3f608587 --- /dev/null +++ b/app/models/in_metacode_set.rb @@ -0,0 +1,5 @@ +class InMetacodeSet < ActiveRecord::Base + belongs_to :metacode, :class_name => "Metacode", :foreign_key => "metacode_id" + belongs_to :metacode_set, :class_name => "MetacodeSet", :foreign_key => "metacode_set_id" + # attr_accessible :title, :body +end diff --git a/app/models/metacode.rb b/app/models/metacode.rb index 0de248be..c6888ea2 100644 --- a/app/models/metacode.rb +++ b/app/models/metacode.rb @@ -1,10 +1,17 @@ class Metacode < ActiveRecord::Base -has_many :topics + has_many :in_metacode_sets + has_many :metacode_sets, :through => :in_metacode_sets + has_many :topics def hasSelected(user) return true if user.settings.metacodes.include? self.id.to_s return false end + + def inMetacodeSet(metacode_set) + return true if self.metacode_sets.include? metacode_set + return false + end end diff --git a/app/models/metacode_set.rb b/app/models/metacode_set.rb new file mode 100644 index 00000000..6798e568 --- /dev/null +++ b/app/models/metacode_set.rb @@ -0,0 +1,6 @@ +class MetacodeSet < ActiveRecord::Base + belongs_to :user + attr_accessible :desc, :mapperContributed, :name + has_many :in_metacode_sets + has_many :metacodes, :through => :in_metacode_sets +end diff --git a/app/views/admin/_adminpanel.html.erb b/app/views/admin/_adminpanel.html.erb new file mode 100644 index 00000000..11f341e6 --- /dev/null +++ b/app/views/admin/_adminpanel.html.erb @@ -0,0 +1,6 @@ +<%= link_to 'Metacode Sets', metacode_sets_path, { :class => 'button' }%> +<%= link_to 'New Set', new_metacode_set_path, { :class => 'button' }%> +<%= link_to 'Metacodes', metacodes_path, { :class => 'button' }%> +<%= link_to 'New Metacode', new_metacode_path, { :class => 'button' }%> +
+
diff --git a/app/views/in_metacode_sets/_form.html.erb b/app/views/in_metacode_sets/_form.html.erb new file mode 100644 index 00000000..8af37701 --- /dev/null +++ b/app/views/in_metacode_sets/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@in_metacode_set) do |f| %> + <% if @in_metacode_set.errors.any? %> +
+

<%= pluralize(@in_metacode_set.errors.count, "error") %> prohibited this in_metacode_set from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :metacode %>
+ <%= f.text_field :metacode %> +
+
+ <%= f.label :metacode_set %>
+ <%= f.text_field :metacode_set %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/in_metacode_sets/edit.html.erb b/app/views/in_metacode_sets/edit.html.erb new file mode 100644 index 00000000..c94b7b78 --- /dev/null +++ b/app/views/in_metacode_sets/edit.html.erb @@ -0,0 +1,6 @@ +

Editing in_metacode_set

+ +<%= render 'form' %> + +<%= link_to 'Show', @in_metacode_set %> | +<%= link_to 'Back', in_metacode_sets_path %> diff --git a/app/views/in_metacode_sets/index.html.erb b/app/views/in_metacode_sets/index.html.erb new file mode 100644 index 00000000..57753a5d --- /dev/null +++ b/app/views/in_metacode_sets/index.html.erb @@ -0,0 +1,25 @@ +

Listing in_metacode_sets

+ + + + + + + + + + +<% @in_metacode_sets.each do |in_metacode_set| %> + + + + + + + +<% end %> +
MetacodeMetacode set
<%= in_metacode_set.metacode %><%= in_metacode_set.metacode_set %><%= link_to 'Show', in_metacode_set %><%= link_to 'Edit', edit_in_metacode_set_path(in_metacode_set) %><%= link_to 'Destroy', in_metacode_set, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New In metacode set', new_in_metacode_set_path %> diff --git a/app/views/in_metacode_sets/new.html.erb b/app/views/in_metacode_sets/new.html.erb new file mode 100644 index 00000000..0e1d596b --- /dev/null +++ b/app/views/in_metacode_sets/new.html.erb @@ -0,0 +1,5 @@ +

New in_metacode_set

+ +<%= render 'form' %> + +<%= link_to 'Back', in_metacode_sets_path %> diff --git a/app/views/in_metacode_sets/show.html.erb b/app/views/in_metacode_sets/show.html.erb new file mode 100644 index 00000000..2b69e016 --- /dev/null +++ b/app/views/in_metacode_sets/show.html.erb @@ -0,0 +1,15 @@ +

<%= notice %>

+ +

+ Metacode: + <%= @in_metacode_set.metacode %> +

+ +

+ Metacode set: + <%= @in_metacode_set.metacode_set %> +

+ + +<%= link_to 'Edit', edit_in_metacode_set_path(@in_metacode_set) %> | +<%= link_to 'Back', in_metacode_sets_path %> diff --git a/app/views/layouts/_account.html.erb b/app/views/layouts/_account.html.erb index a92887a9..2fa1ebc0 100644 --- a/app/views/layouts/_account.html.erb +++ b/app/views/layouts/_account.html.erb @@ -9,6 +9,9 @@ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6bc75d8a..8d2178db 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,7 +24,7 @@ var imgArray = new Object(); <% Metacode.all.each do |m| %> - imgArray['<%= m.name %>'] = new Image(); imgArray['<%= m.name %>'].src = '/assets/<%= m.icon %>'; + imgArray['<%= m.name %>'] = new Image(); imgArray['<%= m.name %>'].src = '<%= m.icon %>'; <% end %> <%= stylesheet_link_tag "application", :media => "all" %> diff --git a/app/views/main/_filterbymetacode.html.erb b/app/views/main/_filterbymetacode.html.erb index 8bfca541..41ea33f5 100644 --- a/app/views/main/_filterbymetacode.html.erb +++ b/app/views/main/_filterbymetacode.html.erb @@ -9,7 +9,7 @@ <% @list = '' %> <% Metacode.order("name").all.each_with_index do |m, index| %> - <% @list += '
  • ' + m.name + '

    ' + m.name.downcase + '

  • ' %> + <% @list += '
  • ' + m.name + '

    ' + m.name.downcase + '

  • ' %> categoryVisible['<%= m.name %>'] = true; <% end %> diff --git a/app/views/main/_metacodeoptions.html.erb b/app/views/main/_metacodeoptions.html.erb index 7b3556ef..9fbf3b51 100644 --- a/app/views/main/_metacodeoptions.html.erb +++ b/app/views/main/_metacodeoptions.html.erb @@ -7,7 +7,7 @@