diff --git a/Gemfile b/Gemfile index c7ec0462..d54d13d2 100644 --- a/Gemfile +++ b/Gemfile @@ -51,6 +51,3 @@ group :development, :test do gem 'quiet_assets' gem 'tunemygc' end - -# To use Jbuilder templates for JSON -gem 'jbuilder' diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 7f2c04f0..38ec4ae0 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -928,8 +928,11 @@ Metamaps.TopicCard = { setTimeout(function () { var text = $(element).val(); if (event.type=="paste" || (event.type=="keyup" && event.which==13)){ - if (text.slice(0, 4) !== 'http') { - text='http://'+text; + // TODO evaluate converting this to '//' no matter what (infer protocol) + if (text.slice(0, 7) !== 'http://' && + text.slice(0, 8) !== 'https://' && + text.slice(0, 2) !== '//') { + text='//'+text; } topic.save({ link: text @@ -1897,7 +1900,7 @@ Metamaps.Util = { return (url.match(/\.(jpeg|jpg|gif|png)$/) != null); }, checkURLisYoutubeVideo: function (url) { - return (url.match(/^http:\/\/(?:www\.)?youtube.com\/watch\?(?=[^?]*v=\w+)(?:[^\s?]+)?$/) != null); + return (url.match(/^https?:\/\/(?:www\.)?youtube.com\/watch\?(?=[^?]*v=\w+)(?:[^\s?]+)?$/) != null); } }; // end Metamaps.Util @@ -1907,8 +1910,8 @@ Metamaps.Util = { * */ Metamaps.Realtime = { - stringForLocalhost: 'http://' + location.host.split(':')[0] + ':5001', - stringForMetamaps: 'http://metamaps.cc:5001', + stringForLocalhost: '//' + location.host.split(':')[0] + ':5001', + stringForMetamaps: 'https://realtime.metamaps.cc', stringForHeroku: 'https://gentle-savannah-1303.herokuapp.com', videoId: 'video-wrapper', socket: null, @@ -3226,7 +3229,6 @@ Metamaps.Control = { if (edge.getData("synapses").length - 1 === 0) { Metamaps.Control.hideEdge(edge); } - var mappableid = synapse.id; synapse.destroy(); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4278637f..7e9339c3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,16 +2,22 @@ class ApplicationController < ActionController::Base protect_from_forgery before_filter :get_invite_link - + # this is for global login include ContentHelper - + helper_method :user helper_method :authenticated? helper_method :admin? - + def after_sign_in_path_for(resource) - sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http') + unsafe_uri = request.env["REQUEST_URI"] + if unsafe_uri.starts_with?('http') && !unsafe_uri.starts_with?('https') + protocol = 'http' + else + protocol = 'https' + end + sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => protocol) if request.referer == sign_in_url super @@ -21,7 +27,7 @@ class ApplicationController < ActionController::Base stored_location_for(resource) || request.referer || root_path end end - + private def require_no_user @@ -30,29 +36,29 @@ private return false end end - + def require_user unless authenticated? redirect_to new_user_session_path, notice: "You must be logged in." return false end end - + def require_admin unless authenticated? && admin? redirect_to root_url, notice: "You need to be an admin for that." return false end end - + def user current_user end - + def authenticated? current_user end - + def admin? current_user && current_user.admin end @@ -60,7 +66,7 @@ private def get_invite_link unsafe_uri = request.env["REQUEST_URI"] valid_url = /^https?:\/\/([\w\.-]+)(:\d{1,5})?\/?$/ - safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : "http://metamaps.cc/" + safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : "//metamaps.cc/" @invite_link = "#{safe_uri}join" + (current_user ? "?code=#{current_user.code}" : "") end end diff --git a/app/models/map.rb b/app/models/map.rb index ca447894..a8b00fd7 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -14,11 +14,11 @@ class Map < ActiveRecord::Base #:full => ['940x630#', :png] }, :default_url => 'https://s3.amazonaws.com/metamaps-assets/site/missing-map.png' - + # Validate the attached image is image/jpg, image/png, etc validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/ - def mappings + def mappings topicmappings + synapsemappings end @@ -35,11 +35,11 @@ class Map < ActiveRecord::Base #return an array of the contributors to the map def contributors contributors = [] - + self.mappings.each do |m| contributors.push(m.user) if !contributors.include?(m.user) end - + return contributors end @@ -59,7 +59,7 @@ class Map < ActiveRecord::Base self.user.image.url end - def contributor_count + def contributor_count self.contributors.length end @@ -83,7 +83,7 @@ class Map < ActiveRecord::Base end ##### PERMISSIONS ###### - + def authorize_to_delete(user) if (self.user != user) return false @@ -98,9 +98,9 @@ class Map < ActiveRecord::Base end return self end - + # returns false if user not allowed to 'edit' Topic, Synapse, or Map - def authorize_to_edit(user) + def authorize_to_edit(user) if !user return false elsif (self.permission == "private" && self.user != user) @@ -110,9 +110,9 @@ class Map < ActiveRecord::Base end return self end - + # returns Boolean if user allowed to view Topic, Synapse, or Map - def authorize_to_view(user) + def authorize_to_view(user) if (self.permission == "private" && self.user != user) return false end @@ -121,7 +121,7 @@ class Map < ActiveRecord::Base def decode_base64(imgBase64) decoded_data = Base64.decode64(imgBase64) - + data = StringIO.new(decoded_data) data.class_eval do attr_accessor :content_type, :original_filename diff --git a/app/models/metacode.rb b/app/models/metacode.rb index a1184e9c..ff9591db 100644 --- a/app/models/metacode.rb +++ b/app/models/metacode.rb @@ -1,31 +1,16 @@ class Metacode < ActiveRecord::Base has_many :in_metacode_sets - has_many :metacode_sets, :through => :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 - - def asset_path_icon - if icon.start_with?('http') - icon - else - ActionController::Base.helpers.asset_path icon - end - end - - #output json with asset_paths merged in - def as_json(options) - json = super(options.merge!(methods: :asset_path_icon)) - json["icon"] = json["asset_path_icon"] - json.except("asset_path_icon") - end end diff --git a/app/models/user.rb b/app/models/user.rb index a9389452..7aafe7c9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -66,15 +66,10 @@ class User < ActiveRecord::Base def generate_code self.code = rand(36**8).to_s(36) $codes.push(self.code) - self.generation = self.get_generation + self.generation = get_generation! end - def get_generation - calculate_generation() if generation.nil? - generation - end - - def calculate_generation + def get_generation! if code == joinedwithcode update(generation: 0) else diff --git a/app/views/layouts/_lightboxes.html.erb b/app/views/layouts/_lightboxes.html.erb index 46ab2edf..1ea13866 100644 --- a/app/views/layouts/_lightboxes.html.erb +++ b/app/views/layouts/_lightboxes.html.erb @@ -46,6 +46,7 @@
While it's downloading, explore our blog,
watch the tutorials, or visit our knowledge base!
@@ -200,13 +203,14 @@
Want to help with design, code, community building, or communications for Metamaps? We're an open value network, which for us means we want to invite and empower peers to participate in creating value together. + <% # TODO change this link to https once it works %>
To be a USER, request an invite! We'll expect you to abide by our terms of service.
To be a CONTRIBUTOR, simply enter our spaces and join the conversation! We'll expect you to follow some guidelines.
MEMBERS are contributors who act as stewards and guardians of the collective and are responsible for maintaining our culture and purpose. We're working on a set of agreements to formalize what it means to be a member.
-We welcome people of all skillsets to create value within our network. There's open possibilities for designers, researchers, academics, strategists, and facilitators to contribute. If you're a developer, help us advance the code and take a look around our Github.
+We welcome people of all skillsets to create value within our network. There's open possibilities for designers, researchers, academics, strategists, and facilitators to contribute. If you're a developer, help us advance the code and take a look around our Github.
Thanks for your interest in helping out with Metamaps! Hopefully this gets you pointed in the right direction to get involved. The next step is to read the links on this page and then contribute!
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9911466a..8057d576 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,7 +16,7 @@ <%= javascript_include_tag "application" %> - + @@ -141,16 +141,12 @@ // set up uservoice with signed in user <% if authenticated? && ENV['SSO_KEY'] %> - USERVOICE.load(Metamaps.Active.Mapper.name, Metamaps.Active.Mapper.id, "<%= user.email %>", "<%= current_sso_token %>"); + USERVOICE.load(Metamaps.Active.Mapper.name, Metamaps.Active.Mapper.id, "<%= user.email %>", "<%= current_sso_token %>"); <% else %> - USERVOICE.load(); + USERVOICE.load(); <% end %> -<% if !authenticated? %> - -<% end %> - <%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %>