diff --git a/.example-env b/.example-env index 3e8752fb..c8fb94af 100644 --- a/.example-env +++ b/.example-env @@ -16,3 +16,16 @@ SSO_KEY # for a uniq ordered list of env vars: ## grep -rIsoh -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" | grep -oP "[A-Z_]+" | sort -u > temp +RUBY_GC_TUNE=0 #set to 1 to enable GC test +RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928 +RUBY_GC_HEAP_INIT_SLOTS=186426 +RUBY_GC_HEAP_FREE_SLOTS=559278 +RUBY_GC_HEAP_GROWTH_FACTOR=1.03 +RUBY_GC_HEAP_GROWTH_MAX_SLOTS=74570 +RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.4 +RUBY_GC_MALLOC_LIMIT=32883406 +RUBY_GC_MALLOC_LIMIT_MAX=69055153 +RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.68 +RUBY_GC_OLDMALLOC_LIMIT=32509481 +RUBY_GC_OLDMALLOC_LIMIT_MAX=68269910 +RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.4 diff --git a/.gitignore b/.gitignore index 9eded787..c6358ead 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,6 @@ log/*.log tmp .DS_Store +*/.DS_Store +.DS_Store? .vagrant diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 00000000..f4597680 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +metamaps_gen002 diff --git a/.ruby-version b/.ruby-version index ac2cdeba..378bc559 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.1.3 +ruby-2.1.3 diff --git a/Gemfile b/Gemfile index 80ac4f64..4f4b0d73 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'uservoice-ruby' gem 'dotenv' gem 'paperclip' -gem 'aws-sdk' +gem 'aws-sdk', '< 2.0' gem 'jquery-rails' gem 'jquery-ui-rails' @@ -54,4 +54,5 @@ group :development, :test do gem 'better_errors' gem 'binding_of_caller' gem 'quiet_assets' + gem 'tunemygc' end diff --git a/Gemfile.lock b/Gemfile.lock index f8de0ac1..27e9e40f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,12 +37,11 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) - aws-sdk (2.1.32) - aws-sdk-resources (= 2.1.32) - aws-sdk-core (2.1.32) - jmespath (~> 1.0) - aws-sdk-resources (2.1.32) - aws-sdk-core (= 2.1.32) + aws-sdk (1.66.0) + aws-sdk-v1 (= 1.66.0) + aws-sdk-v1 (1.66.0) + json (~> 1.4) + nokogiri (>= 1.4.4) bcrypt (3.1.10) best_in_place (3.0.3) actionpack (>= 3.2) @@ -98,7 +97,6 @@ GEM jbuilder (2.3.2) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) - jmespath (1.1.3) jquery-rails (4.0.5) rails-dom-testing (~> 1.0) railties (>= 4.2.0) @@ -213,6 +211,7 @@ GEM thor (0.19.1) thread_safe (0.3.5) tilt (2.0.1) + tunemygc (1.0.61) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.7.2) @@ -229,7 +228,7 @@ PLATFORMS ruby DEPENDENCIES - aws-sdk + aws-sdk (< 2.0) best_in_place better_errors binding_of_caller @@ -256,6 +255,7 @@ DEPENDENCIES redis rspec-rails sass-rails + tunemygc uglifier uservoice-ruby diff --git a/README.md b/README.md index 1e23d33b..4a74151a 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ OR create a new account at `/join`, and use access code `qwertyui` Start mapping and programming! -While we are still figuring out vagrant for Windows, there is an older set of instructions below +We haven't figured out Vagrant for Windows yet, but we have a set of manual instructions here: + - [For Windows][windows-installation] ## Contributing @@ -72,6 +73,6 @@ Copyright (c) 2015 Connor Turland [site-beta]: http://metamaps.cc [community]: https://plus.google.com/u/0/communities/115060009262157699234 [license]: https://github.com/metamaps/metamaps_gen002/blob/master/LICENSE -[contributing]: https://github.com/metamaps/metamaps_gen002/blob/master/CONTRIBUTING.md -[contributing-issues]: https://github.com/metamaps/metamaps_gen002/blob/master/CONTRIBUTING.md#reporting-bugs-and-other-issues -[windows-installation]: https://github.com/metamaps/metamaps_gen002/blob/master/WindowsInstallation.md +[contributing]: https://github.com/metamaps/metamaps_gen002/blob/master/doc/CONTRIBUTING.md +[contributing-issues]: https://github.com/metamaps/metamaps_gen002/blob/master/doc/CONTRIBUTING.md#reporting-bugs-and-other-issues +[windows-installation]: https://github.com/metamaps/metamaps_gen002/blob/master/doc/WindowsInstallation.md diff --git a/WindowsInstallation.md b/WindowsInstallation.md deleted file mode 100644 index 42364b44..00000000 --- a/WindowsInstallation.md +++ /dev/null @@ -1,49 +0,0 @@ -First off, Metamaps runs on Ruby On Rails. Ruby 2.1.3 and Rails 3.2. You'll need to get Ruby and Rails installed on your computer if you don't already have it. Go to here for Ruby http://rubyinstaller.org/downloads/ - -You'll also need GIT: http://git-scm.com/download/win - -It uses postgreSQL 9.2 as a database. You can install that for your computer from here: http://www.enterprisedb.com/products-services-training/pgdownload . During installation you can choose whatever database password you like. Make sure to note it down! - -Once you install those, open a 'command prompt with ruby'. - -to install rails - gem install rails -v 3.2 - -also download node.js, which is also needed http://nodejs.org/download/ - -Navigate to the folder that you want to download the metamaps files to and run the following: (use your forked git repository address if it's different than this repo. You will also need to go to your Github account settings and add the SSH key that was placed in your clipboard earlier) - - git clone https://github.com/metamaps/metamaps_gen002.git --branch develop - cd metamaps_gen002 - -Now you're in the main directory. - -Install all the gems needed for Metamaps by running - - bundle install - -Setting up the database: - -1) Copy /config/database.yml.default and rename the copy to /config/database.yml then edit database.yml with your text editor and set the password to whatever you chose when you set up the PostGres database. - -2) In a terminal: - - rake db:create - rake db:schema:load - rake db:fixtures:load - -Running the server: - - rails s - -Navigate your browser to localhost:3000 once you have the server running - -Sign in with the default account - -email: user@user.com - -password: toolsplusconsciousness - -OR create a new account at /join, and use access code 'qwertyui' - -Start mapping and programming! diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb index 5c575e88..2e17ffae 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb @@ -459,7 +459,7 @@ Metamaps.GlobalUI.Search = { $('.sidebarSearch .twitter-typeahead, .sidebarSearch .tt-hint, .sidebarSearchField').animate({ width: '0' }, 300, function () { - $('.sidebarSearchField').typeahead('setQuery', ''); + $('.sidebarSearchField').typeahead('val', ''); $('.sidebarSearchField').blur(); self.changing = false; self.isOpen = false; @@ -477,95 +477,109 @@ Metamaps.GlobalUI.Search = { var topics = { name: 'topics', limit: 9999, - dupChecker: function (datum1, datum2) { - return false; - }, - template: $('#topicSearchTemplate').html(), - remote: { - url: '/search/topics?term=%QUERY', - replace: function () { - var q = '/search/topics?term=' + $('.sidebarSearchField').val(); - if (Metamaps.Active.Mapper && $("#limitTopicsToMe").is(':checked')) { - q += "&user=" + Metamaps.Active.Mapper.id.toString(); - } - return q; + + display: function(s) { return s.label; }, + templates: { + notFound: function(s) { + return Hogan.compile($('#topicSearchTemplate').html()).render({ + value: "No results", + label: "No results", + typeImageURL: "<%= asset_path('icons/wildcard.png') %>", + rtype: "noresult" + }); + }, + header: topicheader, + suggestion: function(s) { + return Hogan.compile($('#topicSearchTemplate').html()).render(s); }, - filter: function (dataset) { - if (dataset.length == 0) { - dataset.push({ - value: "No results", - label: "No results", - typeImageURL: "<%= asset_path('icons/wildcard.png') %>", - rtype: "noresult" - }); - } - return dataset; - } }, - engine: Hogan, - header: topicheader + source: new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: '/search/topics', + prepare: function(query, settings) { + settings.url += '?term=' + query; + if (Metamaps.Active.Mapper && $("#limitTopicsToMe").is(':checked')) { + settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); + } + return settings; + }, + }, + }), }; var maps = { name: 'maps', limit: 9999, - dupChecker: function (datum1, datum2) { - return false; - }, - template: $('#mapSearchTemplate').html(), - remote: { - url: '/search/maps?term=%QUERY', - replace: function () { - var q = '/search/maps?term=' + $('.sidebarSearchField').val(); - if (Metamaps.Active.Mapper && $("#limitMapsToMe").is(':checked')) { - q += "&user=" + Metamaps.Active.Mapper.id.toString(); - } - return q; + display: function(s) { return s.label; }, + templates: { + notFound: function(s) { + return Hogan.compile($('#mapSearchTemplate').html()).render({ + value: "No results", + label: "No results", + rtype: "noresult" + }); + }, + header: mapheader, + suggestion: function(s) { + return Hogan.compile($('#mapSearchTemplate').html()).render(s); }, - filter: function (dataset) { - if (dataset.length == 0) { - dataset.push({ - value: "No results", - label: "No results", - rtype: "noresult" - }); - } - return dataset; - } }, - engine: Hogan, - header: mapheader + source: new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: '/search/maps', + prepare: function(query, settings) { + settings.url += '?term=' + query; + if (Metamaps.Active.Mapper && $("#limitMapsToMe").is(':checked')) { + settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); + } + return settings; + }, + }, + }), }; var mappers = { name: 'mappers', limit: 9999, - dupChecker: function (datum1, datum2) { - return false; + display: function(s) { return s.label; }, + templates: { + notFound: function(s) { + return Hogan.compile($('#mapperSearchTemplate').html()).render({ + value: "No results", + label: "No results", + rtype: "noresult", + profile: "<%= asset_path('user.png') %>", + }); + }, + header: mapperheader, + suggestion: function(s) { + return Hogan.compile($('#mapperSearchTemplate').html()).render(s); + }, }, - template: $('#mapperSearchTemplate').html(), - remote: { - url: '/search/mappers?term=%QUERY', - filter: function (dataset) { - if (dataset.length == 0) { - dataset.push({ - profile: "<%= asset_path('user.png') %>", - - value: "No results", - label: "No results", - rtype: "noresult" - }); - } - return dataset; - } - }, - engine: Hogan, - header: mapperheader + source: new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: '/search/mappers?term=%QUERY', + wildcard: '%QUERY', + }, + }), }; - $('.sidebarSearchField').typeahead([topics, maps, mappers]); + + // Take all that crazy setup data and put it together into one beautiful typeahead call! + $('.sidebarSearchField').typeahead( + { + highlight: true, + }, + [topics, maps, mappers] + ); //Set max height of the search results box to prevent it from covering bottom left footer - $('.sidebarSearchField').bind('typeahead:suggestionsRendered', function (event) { + $('.sidebarSearchField').bind('typeahead:render', function (event) { self.initSearchOptions(); self.hideLoader(); var h = $(window).height(); @@ -577,7 +591,7 @@ Metamaps.GlobalUI.Search = { }); // tell the autocomplete to launch a new tab with the topic, map, or mapper you clicked on - $('.sidebarSearchField').bind('typeahead:selected', self.handleResultClick); + $('.sidebarSearchField').bind('typeahead:select', self.handleResultClick); // don't do it, if they clicked on a 'addToMap' button $('.sidebarSearch button.addToMap').click(function (event) { @@ -585,7 +599,7 @@ Metamaps.GlobalUI.Search = { }); // make sure that when you click on 'limit to me' or 'toggle section' it works - $('.sidebarSearchField').bind('typeahead:queryChanged', function(){ + $('.sidebarSearchField').bind('typeahead:change', function(){ if ($(this).val() === "") { self.hideLoader(); } @@ -635,7 +649,7 @@ Metamaps.GlobalUI.Search = { $('.limitToMe').unbind().bind("change", function (e) { // set the value of the search equal to itself to retrigger the autocomplete event self.isOpen = false; - $('.sidebarSearchField').typeahead('setQuery', $('.sidebarSearchField').val()); + $('.sidebarSearchField').typeahead('val', $('.sidebarSearchField').val()); setTimeout(function () { self.isOpen = true; }, 2000); diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 84fd38bc..33cb15ef 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -656,7 +656,7 @@ Metamaps.Create = { self.newSelectedMetacodeNames = self.selectedMetacodeNames.slice(0); self.newSelectedMetacodes = self.selectedMetacodes.slice(0); } - $('#metacodeSwitchTabs').tabs("select", self.selectedMetacodeSetIndex); + $('#metacodeSwitchTabs').tabs("option", "active", self.selectedMetacodeSetIndex); $('#topic_name').focus(); }, newTopic: { @@ -3300,26 +3300,34 @@ Metamaps.Filter = { // the first option enables us to accept // ['Topics', 'Synapses'] as 'collection' if (typeof collection === "object") { - Metamaps[collection[0]].each(function(model) { - var prop = model.get(propertyToCheck) ? model.get(propertyToCheck).toString() : false; - if (prop && newList.indexOf(prop) === -1) { - newList.push(prop); - } - }); - Metamaps[collection[1]].each(function(model) { - var prop = model.get(propertyToCheck) ? model.get(propertyToCheck).toString() : false; - if (prop && newList.indexOf(prop) === -1) { - newList.push(prop); - } - }); - } - else if (typeof collection === "string") { - Metamaps[collection].each(function(model) { - var prop = model.get(propertyToCheck) ? model.get(propertyToCheck).toString() : false; - if (prop && newList.indexOf(prop) === -1) { - newList.push(prop); - } - }); + Metamaps[collection[0]].each(function(model) { + var prop = model.get(propertyToCheck); + if (prop !== null) { + prop = prop.toString(); + if (newList.indexOf(prop) === -1) { + newList.push(prop); + } + } + }); + Metamaps[collection[1]].each(function(model) { + var prop = model.get(propertyToCheck); + if (prop !== null) { + prop = prop.toString(); + if (newList.indexOf(prop) === -1) { + newList.push(prop); + } + } + }); + } else if (typeof collection === "string") { + Metamaps[collection].each(function(model) { + var prop = model.get(propertyToCheck); + if (prop !== null) { + prop = prop.toString(); + if (newList.indexOf(prop) === -1) { + newList.push(prop); + } + } + }); } removed = _.difference(self.filters[filtersToUse], newList); diff --git a/app/assets/stylesheets/application.css.erb b/app/assets/stylesheets/application.css.erb index b671dd80..6c036de1 100644 --- a/app/assets/stylesheets/application.css.erb +++ b/app/assets/stylesheets/application.css.erb @@ -2146,6 +2146,7 @@ and it won't be important on password protected instances */ display: block; width: 100%; padding: 4px 0 !important; + outline: none; } .ui-tabs-vertical .ui-tabs-panel { padding: 0 !important; @@ -2182,6 +2183,7 @@ and it won't be important on password protected instances */ } #metacodeSwitchTabs li.ui-state-active a { color: #00BCD4; + cursor: pointer; } .metacodeSwitchTab { max-height: 300px; diff --git a/app/assets/stylesheets/clean.css.erb b/app/assets/stylesheets/clean.css.erb index 94164b6b..8c3bd7dd 100644 --- a/app/assets/stylesheets/clean.css.erb +++ b/app/assets/stylesheets/clean.css.erb @@ -150,470 +150,6 @@ height: 32px; } -/* search */ - -.sidebarSearch { - float:left; - height: 32px; - position: relative; -} - -#searchLoading { - height: 24px; - width: 24px; - position: absolute; - top: 4px; - right: 76px; - display: none; -} - -.unauthenticated .homePage .sidebarSearchIcon { - border-radius: 2px; -} -.sidebarSearchIcon { - float: left; - width: 72px; - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; - height: 32px; - background: #4fb5c0 url(<%= asset_data_uri('search.png') %>) no-repeat center center; - background-size: 32px 32px; - cursor: pointer; -} -.sidebarSearch .twitter-typeahead, .sidebarSearch .sidebarSearchField { - float: left; -} - -.unauthenticated .homePage .sidebarSearchField, -.unauthenticated .homePage .sidebarSearch .tt-hint { - border-top-left-radius: 2px; - border-bottom-left-radius: 2px; -} -.explorePage .sidebarSearchField, -.explorePage .sidebarSearch .tt-hint { - width: 380px; - padding: 5px 10px 5px 10px; -} - -.sidebarSearchField { - color: #424242; -} -.sidebarSearch .tt-hint { - color: transparent; -} -.sidebarSearchField, -.sidebarSearch .tt-hint { - height: 20px; - border-top: 1px solid #BDBDBD; - border-bottom: 1px solid #BDBDBD; - border-left: none; - border-right: none; - padding: 5px 0 5px 0; - width: 0px; - margin: 0; - outline: none; - font-size: 14px; - line-height: 14px; - background: #F5F5F5; - font-family: 'din-medium', helvetica, sans-serif; -} -.sidebarSearch .tt-dropdown-menu { - top: 40px !important; - background: #F5F5F5; - width: 472px; - overflow-y: auto; - overflow-x: visible; - box-shadow: 0 10px 10px rgba(0,0,0,0.19), 0 6px 3px rgba(0,0,0,0.23); -} - -.autoOptions #mapContribs { - width: 15px; - height: 15px; - border: 1px solid #424242; - margin-top: 4px; - margin-left: 4px; -} - -.mapContributorsIcon span { - margin-left: 5px; -} - -.mapContributorsIcon li span { - margin-left: 10px; -} - - -.searchHeader { - height: 42px; - width: 100%; - position: relative; -} -.searchTopicsHeader { - background: #4fc4a8; -} -.searchMapsHeader { - background: #994fc0; -} -.searchMappersHeader { - background: #c04f4f; -} -.sidebarSearch .tt-dropdown-menu h3 { - text-transform: uppercase; - color: #F5F5F5; - font-size: 18px; - line-height: 18px; - margin: 12px 0 3px 16px; - float: left; -} -.sidebarSearch .tt-dropdown-menu .limitToMe { - float: left; - width: 12px; - height: 12px; - border: 1px; - color: #000000; - position: absolute; - top: 15px; - left: 136px; -} -.sidebarSearch .tt-dropdown-menu .limitToMeLabel { - float: left; - font-family: 'din-medium', helvetica, sans-serif; - font-size: 12px; - color: #f5f5f5; - margin: 0; - position: absolute; - top: 15px; - left: 156px; -} -.sidebarSearch .tt-dropdown-menu .minimizeResults, .sidebarSearch .tt-dropdown-menu .maximizeResults { - width: 32px; - height: 32px; - background-image: url(<%= asset_data_uri('arrowpermswhite_sprite.png') %>); - background-repeat: no-repeat; - cursor: pointer; - position: absolute; - top: 5px; - left: 410px; -} -.sidebarSearch .tt-dropdown-menu .minimizeResults { - background-position: 0 0; -} -.sidebarSearch .tt-dropdown-menu .maximizeResults { - background-position: -32px 0; -} -.sidebarSearch .tt-dataset { - overflow: visible; -} -.sidebarSearch .tt-suggestion { - position: relative; - background: #FFF; - padding: 8px 0; -} -.sidebarSearch .tt-is-under-cursor, -.sidebarSearch .tt-suggestion:hover { - background: #E0E0E0; -} - -.resultmap, .resulttopic, .resultmapper, .resultnoresult { - min-height: 48px; - display: table; -} -/*.sidebarSearch .tt-dataset-maps .tt-is-under-cursor .resultmap, -.sidebarSearch .tt-dataset-maps .tt-is-under-mouse-cursor .resultmap, -.sidebarSearch .tt-dataset-topics .tt-is-under-cursor .resulttopic, -.sidebarSearch .tt-dataset-topics .tt-is-under-mouse-cursor .resulttopic { - min-height: 48px; -}*/ -.sidebarSearch .tt-suggestion .searchResIconWrapper { - display: table-cell; - vertical-align: middle; - height: 32px; - padding: 0 18px 0 28px; -} -.sidebarSearch .tt-suggestion .icon { - width: 32px; - height: 32px; - border-radius:16px; -} -.sidebarSearch .topicMetacode { - display: table-cell; - vertical-align: middle; - padding: 0 0 0 8px; - width: 70px; -} -.sidebarSearch .tt-dataset-topics .topicIcon { - width: 32px; - height: 32px; - margin: 0 auto; -} -.sidebarSearch .tt-dataset-topics .metacodeTip { - display: none; - margin: 0 auto; -} -.sidebarSearch .tt-dataset-topics .tt-is-under-cursor .metacodeTip, -.sidebarSearch .tt-dataset-topics .tt-is-under-mouse-cursor .metacodeTip { - display: block; - font-family: 'vinyl'; - text-transform: uppercase; - font-style: italic; - font-size: 13px; - margin: 0 5px 0 2px; - text-align: center; -} -.sidebarSearch .tt-dataset-mappers .tt-suggestion .icon { - margin: 0px 0px 0px 0px; -} -.sidebarSearch .tt-dataset-mappers .resultText { - width: 150px; -} - -.sidebarSearch .resultText { - width: 260px; - display: table-cell; - padding-left: 8px; - vertical-align: middle; - word-wrap: break-word; -} -.sidebarSearch .resultTitle { - font-weight: normal; - font-size: 16px; - line-height: 20px; - width: 100%; - font-family: 'din-regular', helvetica, sans-serif; -} -.sidebarSearch .resultDesc { - font-size: 12px; - line-height: 16px; - width: 100%; - font-style: italic; - font-family: helvetica, sans-serif; -} -.sidebarSearch .tip { - display: none; -} -.sidebarSearch div.autoOptions { - width: 114px; - height: 48px; - position: absolute; - display: none; - top: 8px; - right: 0; -} -.tt-dataset-maps div.autoOptions { - width: 84px; -} -.sidebarSearch .tt-dataset-mappers .autoOptions { - width: 235px; -} -.sidebarSearch .tt-is-under-cursor .autoOptions, -.sidebarSearch .tt-is-under-mouse-cursor .autoOptions { - display: block; -} -.sidebarSearch .tt-suggestion .resultnoresult .autoOptions { - display: none; -} -.sidebarSearch .autoOptions button, -.sidebarSearch .autoOptions a, -.sidebarSearch .autoOptions div { - position: absolute; - padding: 0; - margin: 0; - border: none; - outline: none; -} -.sidebarSearch button.addToMap { - display:none; - width: 24px; - height: 24px; - background: url(<%= asset_data_uri('addtopic_sprite.png') %>); - background-repeat: no-repeat; - background-size: 48px 24px; - top: 12px; - left: 80px; - cursor: pointer; -} -.canEditMap button.addToMap { - display: block; -} -.sidebarSearch button.addToMap:hover { - background-position: -24px; -} - -.sidebarSearch div.topicCount { - width: 24px; - height: 24px; - background: url(<%= asset_data_uri('topic16.png') %>); - background-repeat: no-repeat; - background-position: 0 center; - top: 0; - left: 0; - padding-left: 18px; - font-size: 12px; - line-height: 24px; -} - -.sidebarSearch div.mapCount { - width: 24px; - height: 24px; - background: url(<%= asset_data_uri('metamap16.png') %>); - background-repeat: no-repeat; - background-position: 0 center; - left: 0; - padding-left: 20px; - font-size: 12px; - line-height: 24px; -} -.sidebarSearch div.synapseCount { - width: 24px; - height: 24px; - background: url(<%= asset_data_uri('synapse16.png') %>); - background-repeat: no-repeat; - background-position: 0 center; - top: 24px; - left: 0; - padding-left: 20px; - font-size: 12px; - line-height: 24px; -} -.sidebarSearch div.topicOriginatorIcon { - width: 18px; - height: 18px; - padding: 3px; - top: 0; - left: 44px; -} -.sidebarSearch .topicOriginatorIcon img { - border-radius: 9px; -} - -.sidebarSearch .topicOriginatorIcon .tip { - right: 30px; - top: 1px; -} -.sidebarSearch .tip { - position: absolute; - background: #424242; - width: auto; - top: 2px; - right: 25px; - color: white; - white-space: nowrap; - border-radius: 2px; - font-size: 12px !important; - font-family: 'din-regular'; - line-height: 12px; - padding: 4px 4px 4px; - z-index: 100; -} -.sidebarSearch .hoverForTip:hover .tip { - display: block; -} - -.sidebarSearch .mapContributorsIcon .tip { - right: 40px; - top: -5px; - padding-top: 5px; - padding-bottom: 5px; -} - -.sidebarSearch .hoverForTip .tip li { - padding-left: 28px; - padding-top: 4px; -} - -.tipUserImage { - position: absolute; - top: 0px; - left: 7px; - border-radius: 14px; -} - -.sidebarSearch .hoverForTip .tip:before { - content: ''; - position: absolute; - width: 0; - height: 0; - border-left: 4px solid #424242; - border-top: 5px solid transparent; - border-bottom: 5px solid transparent; -} - -.sidebarSearch .hoverForTip.addToMap .tip { - right: 30px; -} -.sidebarSearch .hoverForTip.addToMap .tip:before { - right: -4px; -} - -.sidebarSearch .mapContributorsIcon .tip:before { - top: 12px; - right: -4px; -} - -.sidebarSearch .topicOriginatorIcon .tip:before { - top: 5px; - right: -4px; -} - -.sidebarSearch .mapContributorsIcon .mapContributors { - top: auto; - right: 0; - bottom: 21px; - white-space: normal; - width: 200px; -} -.sidebarSearch div.mapContributorsIcon { - height: 24px; - top: 0; - left: 44px; - font-size: 12px; - line-height: 24px; -} -.sidebarSearch div.topicPermission, -.sidebarSearch div.mapPermission { - width: 24px; - height: 24px; - background-image: url(<%= asset_data_uri('permissions32_sprite.png') %>); - background-repeat: no-repeat; - background-size: 72px 48px !important; - top: 24px; - left: 44px; -} -.sidebarSearch div.topicPermission.commons, -.sidebarSearch div.mapPermission.commons { - background-position: 0 0; -} -.sidebarSearch div.topicPermission.public, -.sidebarSearch div.mapPermission.public { - background-position: -48px 0; -} -.sidebarSearch div.topicPermission.private, -.sidebarSearch div.mapPermission.private { - background-position: -24px 0; -} - -.sidebarSearch .tt-dataset-mappers div.mapCount { - top: 8px; - left: 170px; -} -.sidebarSearch .tt-dataset-mappers div.mapperCreated { - left: 0px; - padding-left: 0px; - font-size: 12px; - font-family: 'din-medium', helvetica, sans-serif; - line-height: 24px; -} -.sidebarSearch .tt-dataset-mappers div.mapperGeneration { - top: 20px; - left: 0px; - padding-left: 0px; - font-size: 12px; - font-family: 'din-medium', helvetica, sans-serif; - line-height: 24px; -} - -/* end search */ - /* end upperLeftUI */ /* upperRightUI */ diff --git a/app/assets/stylesheets/jquery.mCustomScrollbar.css b/app/assets/stylesheets/jquery.mCustomScrollbar.css.erb similarity index 96% rename from app/assets/stylesheets/jquery.mCustomScrollbar.css rename to app/assets/stylesheets/jquery.mCustomScrollbar.css.erb index f799cdc4..e8588f35 100644 --- a/app/assets/stylesheets/jquery.mCustomScrollbar.css +++ b/app/assets/stylesheets/jquery.mCustomScrollbar.css.erb @@ -162,7 +162,6 @@ .mCSB_scrollTools .mCSB_buttonDown, .mCSB_scrollTools .mCSB_buttonLeft, .mCSB_scrollTools .mCSB_buttonRight{ - background-image:url(<%= asset_data_uri('mCSB_buttons.png') %>); background-repeat:no-repeat; opacity:0.4; filter:"alpha(opacity=40)"; -ms-filter:"alpha(opacity=40)"; /* old ie */ diff --git a/app/assets/stylesheets/search.scss.erb b/app/assets/stylesheets/search.scss.erb new file mode 100644 index 00000000..607a561f --- /dev/null +++ b/app/assets/stylesheets/search.scss.erb @@ -0,0 +1,498 @@ +#searchLoading { + height: 24px; + width: 24px; + position: absolute; + top: 4px; + right: 76px; + display: none; +} + +.unauthenticated { + .homePage .sidebarSearchIcon { + border-radius: 2px; + } + + .homePage .sidebarSearchField, + .homePage .sidebarSearch .tt-hint { + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; + } +} + +.explorePage .sidebarSearchField, +.explorePage .sidebarSearch .tt-hint { + width: 380px; + padding: 5px 10px 5px 10px; +} + +.sidebarSearchIcon { + float: left; + width: 72px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; + height: 32px; + background: #4fb5c0 url(<%= asset_data_uri('search.png') %>) no-repeat center center; + background-size: 32px 32px; + cursor: pointer; +} + +.autoOptions #mapContribs { + width: 15px; + height: 15px; + border: 1px solid #424242; + margin-top: 4px; + margin-left: 4px; +} + +.mapContributorsIcon span { + margin-left: 5px; +} + +.mapContributorsIcon li span { + margin-left: 10px; +} + +.searchHeader { + height: 42px; + width: 100%; + position: relative; +} +.searchTopicsHeader { + background: #4fc4a8; +} +.searchMapsHeader { + background: #994fc0; +} +.searchMappersHeader { + background: #c04f4f; +} + +.resultmap, .resulttopic, .resultmapper, .resultnoresult { + min-height: 48px; + display: table; + width: 100%; +} + +.canEditMap button.addToMap { + display: block; +} + +.tipUserImage { + position: absolute; + top: 0px; + left: 7px; + border-radius: 14px; +} + +/* main search selector */ + +.sidebarSearch { + float:left; + height: 32px; + position: relative; + + .twitter-typeahead { + float: left; + } + + .sidebarSearchField { + float: left; + height: 20px; + border-top: 1px solid #BDBDBD; + border-bottom: 1px solid #BDBDBD; + border-left: none; + border-right: none; + padding: 5px 0 5px 0; + width: 0px; + margin: 0; + outline: none; + font-size: 14px; + line-height: 14px; + background: #F5F5F5; + font-family: 'din-medium', helvetica, sans-serif; + color: #424242; + } + + .tt-hint { + color: transparent; + height: 20px; + border-top: 1px solid #BDBDBD; + border-bottom: 1px solid #BDBDBD; + border-left: none; + border-right: none; + padding: 5px 0 5px 0; + width: 0px; + margin: 0; + outline: none; + font-size: 14px; + line-height: 14px; + background: #F5F5F5; + font-family: 'din-medium', helvetica, sans-serif; + } + + .tt-menu { + top: 40px !important; + background: #F5F5F5; + width: 472px; + overflow-y: auto; + overflow-x: visible; + box-shadow: 0 10px 10px rgba(0,0,0,0.19), 0 6px 3px rgba(0,0,0,0.23); + + h3 { + text-transform: uppercase; + color: #F5F5F5; + font-size: 18px; + line-height: 18px; + margin: 12px 0 3px 16px; + float: left; + } + + .limitToMe { + float: left; + width: 12px; + height: 12px; + border: 1px; + color: #000000; + position: absolute; + top: 15px; + left: 136px; + } + + .limitToMeLabel { + float: left; + font-family: 'din-medium', helvetica, sans-serif; + font-size: 12px; + color: #f5f5f5; + margin: 0; + position: absolute; + top: 15px; + left: 156px; + } + + .minimizeResults, + .maximizeResults { + width: 32px; + height: 32px; + background-image: url(<%= asset_data_uri('arrowpermswhite_sprite.png') %>); + background-repeat: no-repeat; + cursor: pointer; + position: absolute; + top: 5px; + left: 410px; + } + .minimizeResults { + background-position: 0 0; + } + .maximizeResults { + background-position: -32px 0; + } + }/* tt-menu */ + + .tt-suggestion { + position: relative; + background: #FFF; + padding: 8px 0; + + > div { + display: table-cell; + } + + &:hover { + background: #E0E0E0; + } + .icon { + width: 32px; + height: 32px; + border-radius:16px; + } + .resultText { + width: 260px; + padding-left: 8px; + vertical-align: middle; + word-wrap: break-word; + } + .resultTitle { + font-weight: normal; + font-size: 16px; + line-height: 20px; + width: 100%; + font-family: 'din-regular', helvetica, sans-serif; + } + .resultDesc { + font-size: 12px; + line-height: 16px; + width: 100%; + font-style: italic; + font-family: helvetica, sans-serif; + } + + .topicMetacode, + .searchResIconWrapper { + vertical-align: middle; + padding: 0 0 0 8px; + width: 70px; + } + }/* tt-suggestion */ + + .tt-dataset { + overflow: visible; + } + + .tt-dataset-maps { + .autoOptions { + width: 84px; + } + }/* .tt-dataset-maps */ + + .tt-dataset-topics { + .topicIcon { + width: 32px; + height: 32px; + margin: 0 auto; + } + .metacodeTip { + display: none; + margin: 0 auto; + } + .tt-cursor .metacodeTip, + .tt-suggestion:hover .metacodeTip { + display: block; + font-family: 'vinyl'; + text-transform: uppercase; + font-style: italic; + font-size: 13px; + margin: 0 5px 0 2px; + text-align: center; + } + }/* tt-dataset-topics */ + + .tt-dataset-mappers { + .icon { + margin: 0px 0px 0px 0px; + } + .mappers .resultText { + width: 150px; + } + .autoOptions { + width: 235px; + } + .mapCount { + top: 8px; + left: 170px; + } + .mapperCreated { + left: 0px; + padding-left: 0px; + font-size: 12px; + font-family: 'din-medium', helvetica, sans-serif; + line-height: 24px; + } + .mapperGeneration { + top: 20px; + left: 0px; + padding-left: 0px; + font-size: 12px; + font-family: 'din-medium', helvetica, sans-serif; + line-height: 24px; + } + }/* tt-dataset-mappers */ + + .autoOptions { + width: 114px; + height: 48px; + position: absolute; + display: none; + top: 8px; + right: 0; + + a, + div, + button { + position: absolute; + margin: 0; + border: none; + outline: none; + } + }/* .autoOptions */ + + .tt-cursor .autoOptions, + .tt-suggestion:hover .autoOptions { + display: block; + } + .tt-suggestion .resultnoresult .autoOptions { + display: none; + } + + .addToMap { + display:none; + width: 24px; + height: 24px; + background: url(<%= asset_data_uri('addtopic_sprite.png') %>); + background-repeat: no-repeat; + background-size: 48px 24px; + top: 12px; + left: 80px; + cursor: pointer; + + &:hover { + background-position: -24px; + } + }/* .addToMap */ + + .topicCount { + width: 24px; + height: 24px; + background: url(<%= asset_data_uri('topic16.png') %>); + background-repeat: no-repeat; + background-position: 0 center; + top: 0; + left: 0; + padding-left: 18px; + font-size: 12px; + line-height: 24px; + } + + .mapCount { + width: 24px; + height: 24px; + background: url(<%= asset_data_uri('metamap16.png') %>); + background-repeat: no-repeat; + background-position: 0 center; + left: 0; + padding-left: 20px; + font-size: 12px; + line-height: 24px; + } + + .synapseCount { + width: 24px; + height: 24px; + background: url(<%= asset_data_uri('synapse16.png') %>); + background-repeat: no-repeat; + background-position: 0 center; + top: 24px; + left: 0; + padding-left: 20px; + font-size: 12px; + line-height: 24px; + } + + .tip { + display: none; + position: absolute; + background: #424242; + width: auto; + top: 2px; + right: 25px; + color: white; + white-space: nowrap; + border-radius: 2px; + font-size: 12px !important; + font-family: 'din-regular'; + line-height: 12px; + padding: 4px 4px 4px; + z-index: 100; + } + + .topicOriginatorIcon { + width: 18px; + height: 18px; + padding: 3px; + top: 0; + left: 44px; + + img { + border-radius: 9px; + } + + .tip { + right: 30px; + top: 1px; + } + + .tip:before { + top: 5px; + right: -4px; + } + }/* .topicOriginatorIcon */ + + .mapContributorsIcon .tip { + right: 40px; + top: -5px; + padding-top: 5px; + padding-bottom: 5px; + } + + .hoverForTip{ + &:hover .tip { + display: block; + } + + .tip li { + padding-left: 28px; + padding-top: 4px; + } + + .tip:before { + content: ''; + position: absolute; + width: 0; + height: 0; + border-left: 4px solid #424242; + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + } + + .tip { + right: 30px; + } + .tip:before { + right: -4px; + } + }/* .hoverForTip */ + + .mapContributorsIcon { + height: 24px; + top: 0; + left: 44px; + font-size: 12px; + line-height: 24px; + + .tip:before { + top: 12px; + right: -4px; + } + + .mapContributors { + top: auto; + right: 0; + bottom: 21px; + white-space: normal; + width: 200px; + } + }/* .mapContributorsIcon */ + + .topicPermission, + .mapPermission { + width: 24px; + height: 24px; + background-image: url(<%= asset_data_uri('permissions32_sprite.png') %>); + background-repeat: no-repeat; + background-size: 72px 48px !important; + top: 24px; + left: 44px; + + .commons, + .commons { + background-position: 0 0; + } + .public, + .public { + background-position: -48px 0; + } + .private, + .private { + background-position: -24px 0; + } + }/* .topicPermission, .mapPermission */ +}/* .sidebarSearch */ diff --git a/app/assets/stylesheets/uservoice.css.erb b/app/assets/stylesheets/uservoice.css.erb index df15d675..f633c367 100644 --- a/app/assets/stylesheets/uservoice.css.erb +++ b/app/assets/stylesheets/uservoice.css.erb @@ -6,7 +6,7 @@ } div.uv-icon.uv-bottom-left { - background-image:url(<%= asset_data_uri 'feedback_sprite.png' %>); + background-image: url(<%= asset_data_uri 'feedback_sprite.png' %>); background-repeat: no-repeat; color:#FFFFFF; cursor:pointer; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0a3d12ab..4278637f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery + + before_filter :get_invite_link # this is for global login include ContentHelper @@ -47,7 +49,6 @@ private current_user end - def authenticated? current_user end @@ -55,5 +56,11 @@ private def admin? current_user && current_user.admin end - + + 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/" + @invite_link = "#{safe_uri}join" + (current_user ? "?code=#{current_user.code}" : "") + end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index c5535276..1cd0f577 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -26,8 +26,6 @@ class MainController < ApplicationController # get /search/topics?term=SOMETERM def searchtopics - @current = current_user - term = params[:term] user = params[:user] ? params[:user] : false @@ -122,15 +120,13 @@ class MainController < ApplicationController end #read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator - @topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) } + @topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && current_user.id != t.user_id)) } render json: autocomplete_array_json(@topics) end # get /search/maps?term=SOMETERM def searchmaps - @current = current_user - term = params[:term] user = params[:user] ? params[:user] : nil @@ -158,15 +154,13 @@ class MainController < ApplicationController end #read this next line as 'delete a map if its private and you're either 1. logged out or 2. logged in but not the map creator - @maps.to_a.delete_if {|m| m.permission == "private" && (!authenticated? || (authenticated? && @current.id != m.user_id)) } + @maps.to_a.delete_if {|m| m.permission == "private" && (!authenticated? || (authenticated? && current_user.id != m.user_id)) } render json: autocomplete_map_array_json(@maps) end # get /search/mappers?term=SOMETERM def searchmappers - @current = current_user - term = params[:term] if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..5] != "topic:" && term.downcase != "mapper:" @@ -182,8 +176,6 @@ class MainController < ApplicationController # get /search/synapses?term=SOMETERM OR # get /search/synapses?topic1id=SOMEID&topic2id=SOMEID def searchsynapses - @current = current_user - term = params[:term] topic1id = params[:topic1id] topic2id = params[:topic2id] @@ -214,7 +206,7 @@ class MainController < ApplicationController #permissions @synapses.delete_if {|s| s.permission == "private" && !authenticated? } - @synapses.delete_if {|s| s.permission == "private" && authenticated? && @current.id != s.user_id } + @synapses.delete_if {|s| s.permission == "private" && authenticated? && current_user.id != s.user_id } else @synapses = [] end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb deleted file mode 100644 index 5fff2f1c..00000000 --- a/app/controllers/registrations_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Users::RegistrationsController < Devise::RegistrationsController - protected - def after_sign_up_path_for(resource) - signed_in_root_path(resource) - end - - def after_update_path_for(resource) - signed_in_root_path(resource) - end -end diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index dc36ff28..2c3c08d0 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -50,8 +50,7 @@ class SynapsesController < ApplicationController # DELETE synapses/:id def destroy - @current = current_user - @synapse = Synapse.find(params[:id]).authorize_to_delete(@current) + @synapse = Synapse.find(params[:id]).authorize_to_delete(current_user) @synapse.delete if @synapse respond_to do |format| diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 5fff2f1c..c77edb50 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,4 +1,7 @@ class Users::RegistrationsController < Devise::RegistrationsController + before_filter :configure_sign_up_params, only: [:create] + before_filter :configure_account_update_params, only: [:update] + protected def after_sign_up_path_for(resource) signed_in_root_path(resource) @@ -7,4 +10,14 @@ class Users::RegistrationsController < Devise::RegistrationsController def after_update_path_for(resource) signed_in_root_path(resource) end + + private + def configure_sign_up_params + devise_parameter_sanitizer.for(:sign_up) << [:name, :joinedwithcode] + end + + def configure_account_update_params + puts devise_parameter_sanitizer_for(:account_update) + devise_parameter_sanitizer.for(:account_update) << [:image] + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 52996f49..bb645614 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,4 @@ class UsersController < ApplicationController - before_filter :require_user, only: [:edit, :update, :updatemetacodes] respond_to :html, :json @@ -14,7 +13,6 @@ class UsersController < ApplicationController # GET /users/:id/edit def edit @user = current_user - respond_with(@user) end @@ -22,9 +20,9 @@ class UsersController < ApplicationController def update @user = current_user - if params[:user][:password] == "" && params[:user][:password_confirmation] == "" + if user_params[:password] == "" && user_params[:password_confirmation] == "" # not trying to change the password - if @user.update_attributes(params[:user]) + if @user.update_attributes(user_params.except(:password, :password_confirmation)) if params[:remove_image] == "1" @user.image = nil end @@ -43,7 +41,7 @@ class UsersController < ApplicationController # trying to change the password correct_pass = @user.valid_password?(params[:current_password]) - if correct_pass && @user.update_attributes(params[:user]) + if correct_pass && @user.update_attributes(user_params) if params[:remove_image] == "1" @user.image = nil end @@ -101,8 +99,7 @@ class UsersController < ApplicationController private def user_params - params.require(:user).permit(:name, :email, :image, :password, - :password_confirmation, :code, :joinedwithcode, :remember_me) + params.require(:user).permit(:name, :email, :image, :password, :password_confirmation) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fa7876f5..3db990db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,7 +9,7 @@ module ApplicationHelper @m = user.settings.metacodes set = get_metacodeset if set - @metacodes = set.metacodes + @metacodes = set.metacodes.to_a else @metacodes = Metacode.where(id: @m).to_a end diff --git a/app/helpers/maps_helper.rb b/app/helpers/maps_helper.rb index 6b3dd7b0..169ee4b9 100644 --- a/app/helpers/maps_helper.rb +++ b/app/helpers/maps_helper.rb @@ -16,7 +16,7 @@ module MapsHelper map['rtype'] = "map" contributorTip = '' - firstContributorImage = asset_path('user.png') + firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png' if m.contributors.count > 0 firstContributorImage = m.contributors[0].image.url(:thirtytwo) m.contributors.each_with_index do |c, index| diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 977e5709..69335da1 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,22 +1,10 @@ module UsersHelper - - ## this one is for building our custom JSON autocomplete format for typeahead + # build custom json autocomplete for typeahead def autocomplete_user_array_json(users) - temp = [] - users.each do |u| - user = {} - user['id'] = u.id - user['label'] = u.name - user['value'] = u.name - user['profile'] = u.image.url(:sixtyfour) - user['mapCount'] = u.maps.count - user['generation'] = u.generation - user['created_at'] = u.created_at.strftime("%m/%d/%Y") - user['rtype'] = "mapper" - - temp.push user + json_users = [] + users.each do |user| + json_users.push user.as_json_for_autocomplete end - return temp + json_users end - end diff --git a/app/models/map.rb b/app/models/map.rb index eab88814..e6a10605 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -12,7 +12,7 @@ class Map < ActiveRecord::Base :thumb => ['188x126#', :png] #:full => ['940x630#', :png] }, - :default_url => ActionController::Base.helpers.asset_path('missing-map.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/ diff --git a/app/models/user.rb b/app/models/user.rb index effa6ec5..ce68d61b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,11 +35,12 @@ class User < ActiveRecord::Base :ninetysix => ['96x96#', :png], :onetwentyeight => ['128x128#', :png] }, - :default_url => ActionController::Base.helpers.asset_path('user.png') + :default_url => 'https://s3.amazonaws.com/metamaps-assets/site/user.png' # Validate the attached image is image/jpg, image/png, etc validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ + # override default as_json def as_json(options={}) { :id => self.id, :name => self.name, @@ -47,27 +48,37 @@ class User < ActiveRecord::Base :admin => self.admin } end + + def as_json_for_autocomplete + json = {} + json['id'] = id + json['label'] = name + json['value'] = name + json['profile'] = image.url(:sixtyfour) + json['mapCount'] = maps.count + json['generation'] = generation + json['created_at'] = created_at.strftime("%m/%d/%Y") + json['rtype'] = "mapper" + json + end + #generate a random 8 letter/digit code that they can use to invite people def generate_code - #generate a random 8 letter/digit code that they can use to invite people self.code = rand(36**8).to_s(36) - $codes.push(self.code) - self.generation = self.get_generation end def get_generation - if self.joinedwithcode == self.code - # if your joinedwithcode equals your code you must be GEN 0 - gen = 0 - elsif self.generation - # if your generation has already been calculated then just return that value - gen = self.generation + calculate_generation() if generation.nil? + generation + end + + def calculate_generation + if code == joinedwithcode + update(generation: 0) else - # if your generation hasn't been calculated, base it off the - # generation of the person whose code you joined with + 1 - gen = User.find_by_code(self.joinedwithcode).get_generation + 1 + update(generation: User.find_by_code(joinedwithcode).generation + 1) end end @@ -75,13 +86,12 @@ class User < ActiveRecord::Base # make sure we always return a UserPreference instance if read_attribute(:settings).nil? write_attribute :settings, UserPreference.new - read_attribute :settings - else - read_attribute :settings end + read_attribute :settings end def settings=(val) write_attribute :settings, val end + end diff --git a/app/views/layouts/_lightboxes.html.erb b/app/views/layouts/_lightboxes.html.erb index e8b688d5..46ab2edf 100644 --- a/app/views/layouts/_lightboxes.html.erb +++ b/app/views/layouts/_lightboxes.html.erb @@ -231,9 +231,8 @@
As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.
Below is a personal invite link containing your unique access code, which can be used multiple times.
http://metamaps.cc/join?code=<%= mapper.code %>
- +<%= @invite_link %> +