diff --git a/.buildpacks b/.buildpacks index ff2497d3..9fb12425 100644 --- a/.buildpacks +++ b/.buildpacks @@ -1 +1,2 @@ +https://github.com/heroku/heroku-buildpack-nodejs.git https://github.com/heroku/heroku-buildpack-ruby.git diff --git a/.travis.yml b/.travis.yml index 5e192554..28559996 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,6 @@ before_script: - . $HOME/.nvm/nvm.sh - nvm install stable - nvm use stable - - (cd frontend && npm install) + - npm install script: - - bundle exec rspec && (cd frontend && npm test) && bundle exec brakeman -q -z + - bundle exec rspec && npm test && bundle exec brakeman -q -z diff --git a/README.md b/README.md index 20d8db27..26de4e6c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Metamaps ======= [![Join the chat at https://gitter.im/metamaps/metamaps](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/metamaps/metamaps?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://travis-ci.org/metamaps/metamaps.svg)](https://travis-ci.org/metamaps/metamaps) +[![Build Status](https://travis-ci.org/metamaps/metamaps.svg?branch=develop)](https://travis-ci.org/metamaps/metamaps) Welcome to the Metamaps GitHub repo. diff --git a/app/assets/javascripts/src/Metamaps.Control.js b/app/assets/javascripts/src/Metamaps.Control.js index 4db7f82b..da6854c2 100644 --- a/app/assets/javascripts/src/Metamaps.Control.js +++ b/app/assets/javascripts/src/Metamaps.Control.js @@ -111,6 +111,19 @@ Metamaps.Control = { } }, removeSelectedNodes: function () { // refers to removing topics permanently from a map + if (Metamaps.Active.Topic) { + // hideNode will handle synapses as well + var nodeids = _.map(Metamaps.Selected.Nodes, function(node) { + return node.id + }) + _.each(nodeids, function(nodeid) { + if (Metamaps.Active.Topic.id !== nodeid) { + Metamaps.Topics.remove(nodeid) + Metamaps.Control.hideNode(nodeid) + } + }) + return + } if (!Metamaps.Active.Map) return var l = Metamaps.Selected.Nodes.length, @@ -285,12 +298,13 @@ Metamaps.Control = { } }, removeSelectedEdges: function () { + // Topic view is handled by removeSelectedNodes + if (!Metamaps.Active.Map) return + var l = Metamaps.Selected.Edges.length, i, edge - if (!Metamaps.Active.Map) return - var authorized = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper) if (!authorized) { diff --git a/app/assets/javascripts/src/Metamaps.Import.js b/app/assets/javascripts/src/Metamaps.Import.js index a187fe59..30770628 100644 --- a/app/assets/javascripts/src/Metamaps.Import.js +++ b/app/assets/javascripts/src/Metamaps.Import.js @@ -275,7 +275,7 @@ Metamaps.Import = { name: name, metacode_id: metacode.id, permission: permission || Metamaps.Active.Map.get('permission'), - desc: desc, + desc: desc || "", link: link }) Metamaps.Topics.add(topic) @@ -295,7 +295,7 @@ Metamaps.Import = { Metamaps.Famous.viz.hideInstructions() }, - createSynapseWithParameters: function (description, category, permission, + createSynapseWithParameters: function (desc, category, permission, topic1, topic2) { var node1 = topic1.get('node') var node2 = topic2.get('node') @@ -306,7 +306,7 @@ Metamaps.Import = { } // if var synapse = new Metamaps.Backbone.Synapse({ - desc: description, + desc: desc || "", category: category, permission: permission, node1_id: topic1.id, diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 0559a80a..852c1767 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -1084,7 +1084,18 @@ Metamaps.JIT = { } return 'nothing'; // case 4? }, // handleSelectionBeforeDragging + getNodeXY: function(node) { + if (typeof node.pos.x === "number" && typeof node.pos.y === "number") { + return node.pos + } else if (typeof node.pos.theta === "number" && typeof node.pos.rho === "number") { + return new $jit.Polar(node.pos.theta, node.pos.rho).getc(true) + } else { + console.error('getNodeXY: unrecognized node pos format') + return {} + } + }, selectWithBox: function (e) { + var self = this var sX = Metamaps.Mouse.boxStartCoordinates.x, sY = Metamaps.Mouse.boxStartCoordinates.y, eX = Metamaps.Mouse.boxEndCoordinates.x, @@ -1096,11 +1107,17 @@ Metamaps.JIT = { } // select all nodes that are within the box - Metamaps.Visualize.mGraph.graph.eachNode(function (n) { - var x = n.pos.x, - y = n.pos.y + Metamaps.Visualize.mGraph.graph.eachNode(function(n) { + var pos = self.getNodeXY(n) + var x = pos.x, + y = pos.y - if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) { + // depending on which way the person dragged the box, check that + // x and y are between the start and end values of the box + if ((sX < x && x < eX && sY < y && y < eY) || + (sX > x && x > eX && sY > y && y > eY) || + (sX > x && x > eX && sY < y && y < eY) || + (sX < x && x < eX && sY > y && y > eY)) { if (e.shiftKey) { if (n.selected) { Metamaps.Control.deselectNode(n) @@ -1125,10 +1142,12 @@ Metamaps.JIT = { } }) edgesToToggle.forEach(function (edge) { - var fromNodeX = edge.nodeFrom.pos.x - var fromNodeY = -1 * edge.nodeFrom.pos.y - var toNodeX = edge.nodeTo.pos.x - var toNodeY = -1 * edge.nodeTo.pos.y + var fromNodePos = self.getNodeXY(edge.nodeFrom) + var fromNodeX = fromNodePos.x + var fromNodeY = -1 * fromNodePos.y + var toNodePos = self.getNodeXY(edge.nodeTo) + var toNodeX = toNodePos.x + var toNodeY = -1 * toNodePos.y var maxX = fromNodeX var maxY = fromNodeY @@ -1315,10 +1334,11 @@ Metamaps.JIT = { if (Metamaps.Active.Map) menustring += '
  • Hide until refresh
    Ctrl+H
  • ' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '
  • Remove from map
    Ctrl+M
  • ' + if (Metamaps.Active.Topic) menustring += '
  • Remove from view
    Ctrl+M
  • ' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '
  • Delete
    Ctrl+D
  • ' if (Metamaps.Active.Topic) { - menustring += '
  • Center this topic
  • ' + menustring += '
  • Center this topic
    Alt+E
  • ' } menustring += '
  • Open in new tab
  • ' if (Metamaps.Active.Mapper) { @@ -1343,10 +1363,10 @@ Metamaps.JIT = { // set up the get sibling menu as a "lazy load" // only fill in the submenu when they hover over the get siblings list item var siblingMenu = '' - menustring += '
  • Get siblings' + siblingMenu + '
  • ' + menustring += '
  • Reveal siblings' + siblingMenu + '
  • ' } menustring += '' @@ -1399,7 +1419,7 @@ Metamaps.JIT = { } // remove the selected things from the map - if (authorized) { + if (Metamaps.Active.Topic || authorized) { $('.rc-remove').click(function () { $('.rightclickmenu').remove() Metamaps.Control.removeSelectedEdges() @@ -1442,11 +1462,11 @@ Metamaps.JIT = { }) // fetch relatives - var fetched = false + var fetch_sent = false $('.rc-siblings').hover(function () { - if (!fetched) { + if (!fetch_sent) { Metamaps.JIT.populateRightClickSiblings(node) - fetched = true + fetch_sent = true } }) $('.rc-siblings .fetchAll').click(function () { @@ -1459,13 +1479,6 @@ Metamaps.JIT = { var self = Metamaps.JIT // depending on how many topics are selected, do different things - /*if (Metamaps.Selected.Nodes.length > 1) { - // we don't bother filling the submenu with - // specific numbers, because there are too many topics - // selected to find those numbers - $('#loadingSiblings').remove() - return - }*/ var topic = node.getData('topic') @@ -1496,7 +1509,7 @@ Metamaps.JIT = { } $.ajax({ - type: 'Get', + type: 'GET', url: '/topics/' + topic.id + '/relative_numbers.json?network=' + topics_string, success: successCallback, error: function () {} @@ -1569,6 +1582,7 @@ Metamaps.JIT = { if (Metamaps.Active.Map) menustring += '
  • Hide until refresh
    Ctrl+H
  • ' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '
  • Remove from map
    Ctrl+M
  • ' + if (Metamaps.Active.Topic) menustring += '
  • Remove from view
    Ctrl+M
  • ' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '
  • Delete
    Ctrl+D
  • ' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '
  • ' diff --git a/app/assets/javascripts/src/Metamaps.Listeners.js b/app/assets/javascripts/src/Metamaps.Listeners.js index 83204eee..822cf657 100644 --- a/app/assets/javascripts/src/Metamaps.Listeners.js +++ b/app/assets/javascripts/src/Metamaps.Listeners.js @@ -11,6 +11,7 @@ */ Metamaps.Listeners = { init: function () { + var self = this $(document).on('keydown', function (e) { if (!(Metamaps.Active.Map || Metamaps.Active.Topic)) return @@ -35,21 +36,6 @@ Metamaps.Listeners = { Metamaps.Visualize.mGraph.plot() } - break - case 69: // if e or E is pressed - if (e.ctrlKey) { - e.preventDefault() - if (Metamaps.Active.Map) { - Metamaps.JIT.zoomExtents(null, Metamaps.Visualize.mGraph.canvas) - } - } - break - case 77: // if m or M is pressed - if (e.ctrlKey) { - e.preventDefault() - Metamaps.Control.removeSelectedNodes() - Metamaps.Control.removeSelectedEdges() - } break case 68: // if d or D is pressed if (e.ctrlKey) { @@ -57,6 +43,24 @@ Metamaps.Listeners = { Metamaps.Control.deleteSelected() } break + case 69: // if e or E is pressed + if (e.ctrlKey && Metamaps.Active.Map) { + e.preventDefault() + Metamaps.JIT.zoomExtents(null, Metamaps.Visualize.mGraph.canvas) + break + } + if (e.altKey && Metamaps.Active.Topic) { + e.preventDefault() + + if (Metamaps.Active.Topic) { + self.centerAndReveal(Metamaps.Selected.Nodes, { + center: true, + reveal: false + }) + } + break + } + break case 72: // if h or H is pressed if (e.ctrlKey) { e.preventDefault() @@ -64,8 +68,34 @@ Metamaps.Listeners = { Metamaps.Control.hideSelectedEdges() } break + case 77: // if m or M is pressed + if (e.ctrlKey) { + e.preventDefault() + Metamaps.Control.removeSelectedNodes() + Metamaps.Control.removeSelectedEdges() + } + break + case 82: // if r or R is pressed + if (e.altKey && Metamaps.Active.Topic) { + e.preventDefault() + self.centerAndReveal(Metamaps.Selected.Nodes, { + center: false, + reveal: true + }) + } + break + case 84: // if t or T is pressed + if (e.altKey && Metamaps.Active.Topic) { + e.preventDefault() + self.centerAndReveal(Metamaps.Selected.Nodes, { + center: true, + reveal: true + }) + } + break default: - break; // alert(e.which) + // console.log(e.which) + break } }) @@ -74,5 +104,18 @@ Metamaps.Listeners = { if ((Metamaps.Active.Map || Metamaps.Active.Topic) && Metamaps.Famous && Metamaps.Famous.maps.surf) Metamaps.Famous.maps.reposition() if (Metamaps.Active.Map && Metamaps.Realtime.inConversation) Metamaps.Realtime.positionVideos() }) + }, + centerAndReveal: function(nodes, opts) { + if (nodes.length < 1) return + var node = nodes[nodes.length - 1] + if (opts.center && opts.reveal) { + Metamaps.Topic.centerOn(node.id, function() { + Metamaps.Topic.fetchRelatives(nodes) + }) + } else if (opts.center) { + Metamaps.Topic.centerOn(node.id) + } else if (opts.reveal) { + Metamaps.Topic.fetchRelatives(nodes) + } } }; // end Metamaps.Listeners diff --git a/app/assets/javascripts/src/Metamaps.Map.js b/app/assets/javascripts/src/Metamaps.Map.js index 34374614..ec3b946f 100644 --- a/app/assets/javascripts/src/Metamaps.Map.js +++ b/app/assets/javascripts/src/Metamaps.Map.js @@ -673,6 +673,8 @@ Metamaps.Map.InfoBox = { return string }, updateNumbers: function () { + if (!Metamaps.Active.Map) return + var self = Metamaps.Map.InfoBox var mapper = Metamaps.Active.Mapper var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators diff --git a/app/assets/javascripts/src/Metamaps.Topic.js b/app/assets/javascripts/src/Metamaps.Topic.js index b15f8669..f0f68a92 100644 --- a/app/assets/javascripts/src/Metamaps.Topic.js +++ b/app/assets/javascripts/src/Metamaps.Topic.js @@ -99,16 +99,25 @@ Metamaps.Topic = { Metamaps.Filter.close() } }, - centerOn: function (nodeid) { + centerOn: function (nodeid, callback) { + // don't clash with fetchRelatives if (!Metamaps.Visualize.mGraph.busy) { Metamaps.Visualize.mGraph.onClick(nodeid, { hideLabels: false, duration: 1000, - onComplete: function () {} + onComplete: function () { + if (callback) callback() + } }) + Metamaps.Router.navigate('/topics/' + nodeid) + Metamaps.Active.Topic = Metamaps.Topics.get(nodeid) } }, - fetchRelatives: function (node, metacode_id) { + fetchRelatives: function (nodes, metacode_id) { + var self = this + + var node = $.isArray(nodes) ? nodes[0] : nodes + var topics = Metamaps.Topics.map(function (t) { return t.id }) var topics_string = topics.join() @@ -117,7 +126,13 @@ Metamaps.Topic = { var topic = node.getData('topic') - var successCallback = function (data) { + var successCallback; + successCallback = function (data) { + if (Metamaps.Visualize.mGraph.busy) { + // don't clash with centerOn + window.setTimeout(function() { successCallback(data) }, 100) + return + } if (data.creators.length > 0) Metamaps.Creators.add(data.creators) if (data.topics.length > 0) Metamaps.Topics.add(data.topics) if (data.synapses.length > 0) Metamaps.Synapses.add(data.synapses) @@ -153,13 +168,16 @@ Metamaps.Topic = { } }) }) + if ($.isArray(nodes) && nodes.length > 1) { + self.fetchRelatives(nodes.slice(1), metacode_id) + } } var paramsString = metacode_id ? 'metacode=' + metacode_id + '&' : '' paramsString += 'network=' + topics_string + '&creators=' + creators_string $.ajax({ - type: 'Get', + type: 'GET', url: '/topics/' + topic.id + '/relatives.json?' + paramsString, success: successCallback, error: function () {} diff --git a/app/assets/stylesheets/application.css.erb b/app/assets/stylesheets/application.css.erb index 6c76dd9e..d1f866bc 100644 --- a/app/assets/stylesheets/application.css.erb +++ b/app/assets/stylesheets/application.css.erb @@ -1249,8 +1249,9 @@ h3.filterBox { .rightclickmenu .rc-metacode > ul > li, .rightclickmenu .rc-siblings > ul > li { padding: 6px 24px 6px 8px; - width: auto; white-space: nowrap; + width: auto; + min-width: 5em; } .rightclickmenu .rc-metacode ul ul, .rightclickmenu .rc-siblings ul ul { diff --git a/app/views/shared/_cheatsheet.html.erb b/app/views/shared/_cheatsheet.html.erb index c02246ac..e86b2977 100644 --- a/app/views/shared/_cheatsheet.html.erb +++ b/app/views/shared/_cheatsheet.html.erb @@ -26,8 +26,9 @@
    -
    Recenter Topics around chosen Topic: Alt + click on the topic OR Right-click + 'center this topic'
    - +
    Recenter Topics around chosen Topic: Alt + click on the topic OR Alt + E
    +
    Reveal the siblings for a Topic: Right-click and choose 'Reveal siblings' OR Alt + R
    +
    Center topic and reveal siblings: Alt + T
    diff --git a/db/schema.rb b/db/schema.rb index 49081d10..30e2aa1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -29,30 +29,27 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.datetime 'updated_at' end - add_index 'delayed_jobs', %w(priority run_at), name: 'delayed_jobs_priority', using: :btree + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree - create_table 'events', force: :cascade do |t| - t.string 'kind', limit: 255 - t.integer 'eventable_id' - t.string 'eventable_type' - t.integer 'user_id' - t.integer 'map_id' - t.integer 'sequence_id' - t.datetime 'created_at' - t.datetime 'updated_at' + create_table "events", force: :cascade do |t| + t.string "kind", limit: 255 + t.integer "eventable_id" + t.string "eventable_type" + t.integer "user_id" + t.integer "map_id" + t.datetime "created_at" + t.datetime "updated_at" end - add_index 'events', %w(eventable_type eventable_id), name: 'index_events_on_eventable_type_and_eventable_id', using: :btree - add_index 'events', %w(map_id sequence_id), name: 'index_events_on_map_id_and_sequence_id', unique: true, using: :btree - add_index 'events', ['map_id'], name: 'index_events_on_map_id', using: :btree - add_index 'events', ['sequence_id'], name: 'index_events_on_sequence_id', using: :btree - add_index 'events', ['user_id'], name: 'index_events_on_user_id', using: :btree + add_index "events", ["eventable_type", "eventable_id"], name: "index_events_on_eventable_type_and_eventable_id", using: :btree + add_index "events", ["map_id"], name: "index_events_on_map_id", using: :btree + add_index "events", ["user_id"], name: "index_events_on_user_id", using: :btree - create_table 'in_metacode_sets', force: :cascade do |t| - t.integer 'metacode_id' - t.integer 'metacode_set_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false + create_table "in_metacode_sets", force: :cascade do |t| + t.integer "metacode_id" + t.integer "metacode_set_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index 'in_metacode_sets', ['metacode_id'], name: 'index_in_metacode_sets_on_metacode_id', using: :btree @@ -72,25 +69,25 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.string 'mappable_type' end - add_index 'mappings', %w(map_id synapse_id), name: 'index_mappings_on_map_id_and_synapse_id', using: :btree - add_index 'mappings', %w(map_id topic_id), name: 'index_mappings_on_map_id_and_topic_id', using: :btree - add_index 'mappings', ['map_id'], name: 'index_mappings_on_map_id', using: :btree - add_index 'mappings', %w(mappable_id mappable_type), name: 'index_mappings_on_mappable_id_and_mappable_type', using: :btree - add_index 'mappings', ['user_id'], name: 'index_mappings_on_user_id', using: :btree + add_index "mappings", ["map_id", "synapse_id"], name: "index_mappings_on_map_id_and_synapse_id", using: :btree + add_index "mappings", ["map_id", "topic_id"], name: "index_mappings_on_map_id_and_topic_id", using: :btree + add_index "mappings", ["map_id"], name: "index_mappings_on_map_id", using: :btree + add_index "mappings", ["mappable_id", "mappable_type"], name: "index_mappings_on_mappable_id_and_mappable_type", using: :btree + add_index "mappings", ["user_id"], name: "index_mappings_on_user_id", using: :btree - create_table 'maps', force: :cascade do |t| - t.text 'name' - t.boolean 'arranged' - t.text 'desc' - t.text 'permission' - t.integer 'user_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.boolean 'featured' - t.string 'screenshot_file_name' - t.string 'screenshot_content_type' - t.integer 'screenshot_file_size' - t.datetime 'screenshot_updated_at' + create_table "maps", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "name" + t.text "desc" + t.text "permission" + t.integer "user_id" + t.boolean "arranged" + t.boolean "featured" + t.string "screenshot_file_name", limit: 255 + t.string "screenshot_content_type", limit: 255 + t.integer "screenshot_file_size" + t.datetime "screenshot_updated_at" end add_index 'maps', ['user_id'], name: 'index_maps_on_user_id', using: :btree @@ -104,31 +101,31 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.datetime 'updated_at' end - add_index 'messages', ['resource_id'], name: 'index_messages_on_resource_id', using: :btree - add_index 'messages', ['resource_type'], name: 'index_messages_on_resource_type', using: :btree - add_index 'messages', ['user_id'], name: 'index_messages_on_user_id', using: :btree + add_index "messages", ["resource_id"], name: "index_messages_on_resource_id", using: :btree + add_index "messages", ["resource_type"], name: "index_messages_on_resource_type", using: :btree + add_index "messages", ["user_id"], name: "index_messages_on_user_id", using: :btree - create_table 'metacode_sets', force: :cascade do |t| - t.string 'name' - t.text 'desc' - t.integer 'user_id' - t.boolean 'mapperContributed' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false + create_table "metacode_sets", force: :cascade do |t| + t.string "name", limit: 255 + t.text "desc" + t.integer "user_id" + t.boolean "mapperContributed" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index 'metacode_sets', ['user_id'], name: 'index_metacode_sets_on_user_id', using: :btree + add_index "metacode_sets", ["user_id"], name: "index_metacode_sets_on_user_id", using: :btree - create_table 'metacodes', force: :cascade do |t| - t.text 'name' - t.string 'manual_icon' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'color' - t.string 'aws_icon_file_name' - t.string 'aws_icon_content_type' - t.integer 'aws_icon_file_size' - t.datetime 'aws_icon_updated_at' + create_table "metacodes", force: :cascade do |t| + t.text "name" + t.string "manual_icon", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "color", limit: 255 + t.string "aws_icon_file_name" + t.string "aws_icon_content_type" + t.integer "aws_icon_file_size" + t.datetime "aws_icon_updated_at" end create_table 'oauth_access_grants', force: :cascade do |t| @@ -169,19 +166,19 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.datetime 'updated_at' end - add_index 'oauth_applications', ['uid'], name: 'index_oauth_applications_on_uid', unique: true, using: :btree + add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree - create_table 'synapses', force: :cascade do |t| - t.text 'desc' - t.text 'category' - t.text 'weight' - t.text 'permission' - t.integer 'node1_id' - t.integer 'node2_id' - t.integer 'user_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.integer 'defer_to_map_id' + create_table "synapses", force: :cascade do |t| + t.text "desc" + t.text "category" + t.integer "node1_id" + t.integer "node2_id" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "permission" + t.text "weight" + t.integer "defer_to_map_id" end add_index 'synapses', %w(node1_id node1_id), name: 'index_synapses_on_node1_id_and_node1_id', using: :btree @@ -198,26 +195,26 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.datetime 'updated_at', null: false end - add_index 'tokens', ['user_id'], name: 'index_tokens_on_user_id', using: :btree + add_index "tokens", ["user_id"], name: "index_tokens_on_user_id", using: :btree - create_table 'topics', force: :cascade do |t| - t.text 'name' - t.text 'desc' - t.text 'link' - t.text 'permission' - t.integer 'user_id' - t.integer 'metacode_id' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'image_file_name' - t.string 'image_content_type' - t.integer 'image_file_size' - t.datetime 'image_updated_at' - t.string 'audio_file_name' - t.string 'audio_content_type' - t.integer 'audio_file_size' - t.datetime 'audio_updated_at' - t.integer 'defer_to_map_id' + create_table "topics", force: :cascade do |t| + t.text "name" + t.text "desc" + t.text "link" + t.integer "user_id" + t.integer "metacode_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "permission" + t.string "image_file_name", limit: 255 + t.string "image_content_type", limit: 255 + t.integer "image_file_size" + t.datetime "image_updated_at" + t.string "audio_file_name", limit: 255 + t.string "audio_content_type", limit: 255 + t.integer "audio_file_size" + t.datetime "audio_updated_at" + t.integer "defer_to_map_id" end add_index 'topics', ['metacode_id'], name: 'index_topics_on_metacode_id', using: :btree @@ -230,37 +227,37 @@ ActiveRecord::Schema.define(version: 20_160_401_133_937) do t.datetime 'updated_at' end - add_index 'user_maps', ['map_id'], name: 'index_user_maps_on_map_id', using: :btree - add_index 'user_maps', ['user_id'], name: 'index_user_maps_on_user_id', using: :btree + add_index "user_maps", ["map_id"], name: "index_user_maps_on_map_id", using: :btree + add_index "user_maps", ["user_id"], name: "index_user_maps_on_user_id", using: :btree - create_table 'users', force: :cascade do |t| - t.string 'name' - t.string 'email' - t.text 'settings' - t.string 'code', limit: 8 - t.string 'joinedwithcode', limit: 8 - t.string 'crypted_password' - t.string 'password_salt' - t.string 'persistence_token' - t.string 'perishable_token' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'encrypted_password', limit: 128, default: '' - t.string 'remember_token' - t.datetime 'remember_created_at' - t.string 'reset_password_token' - t.datetime 'last_sign_in_at' - t.string 'last_sign_in_ip' - t.integer 'sign_in_count', default: 0 - t.datetime 'current_sign_in_at' - t.string 'current_sign_in_ip' - t.datetime 'reset_password_sent_at' - t.boolean 'admin' - t.string 'image_file_name' - t.string 'image_content_type' - t.integer 'image_file_size' - t.datetime 'image_updated_at' - t.integer 'generation' + create_table "users", force: :cascade do |t| + t.string "name", limit: 255 + t.string "email", limit: 255 + t.string "crypted_password", limit: 255 + t.string "password_salt", limit: 255 + t.string "persistence_token", limit: 255 + t.string "perishable_token", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "code", limit: 8 + t.string "joinedwithcode", limit: 8 + t.text "settings" + t.string "encrypted_password", limit: 128, default: "" + t.string "remember_token", limit: 255 + t.datetime "remember_created_at" + t.string "reset_password_token", limit: 255 + t.datetime "last_sign_in_at" + t.string "last_sign_in_ip", limit: 255 + t.integer "sign_in_count", default: 0 + t.datetime "current_sign_in_at" + t.string "current_sign_in_ip", limit: 255 + t.datetime "reset_password_sent_at" + t.boolean "admin" + t.string "image_file_name", limit: 255 + t.string "image_content_type", limit: 255 + t.integer "image_file_size" + t.datetime "image_updated_at" + t.integer "generation" end add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, using: :btree diff --git a/frontend/test/Metamaps.Import.spec.js b/frontend/test/Metamaps.Import.spec.js index 59ab45e6..8dcf8e97 100644 --- a/frontend/test/Metamaps.Import.spec.js +++ b/frontend/test/Metamaps.Import.spec.js @@ -2,7 +2,7 @@ const chai = require('chai') const expect = chai.expect -const Metamaps = {} +Metamaps = {} require('../../app/assets/javascripts/src/Metamaps.Import') describe('Metamaps.Import.js', function () { diff --git a/lib/tasks/extensions.rake b/lib/tasks/extensions.rake new file mode 100644 index 00000000..bf07cec2 --- /dev/null +++ b/lib/tasks/extensions.rake @@ -0,0 +1,8 @@ +namespace :assets do + task :js_compile do + system "npm install" + system "npm run build" + end +end + +Rake::Task[:'assets:precompile'].enhance([:'assets:js_compile']) diff --git a/package.json b/package.json index d70cd4c0..2da72637 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "metamaps-frontend", + "name": "metamaps", "version": "1.0.0", - "description": "Metamaps frontend - currently just tests", + "description": "Metamaps webpacked javascript code", "scripts": { "build": "webpack", "build:watch": "webpack --watch", - "test": "mocha test || echo 'Run `npm install` to setup testing'" + "test": "mocha frontend/test || (echo 'Run `npm install` to setup testing' && false)" }, "repository": { "type": "git", @@ -17,21 +17,20 @@ "url": "https://github.com/metamaps/metamaps/issues" }, "homepage": "https://github.com/metamaps/metamaps#readme", - "devDependencies": { + "dependencies": { "babel-cli": "^6.11.4", "babel-loader": "^6.2.4", "babel-plugin-transform-class-properties": "^6.11.5", "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.11.1", + "backbone": "^1.0.0", "chai": "^3.5.0", "jquery": "^1.12.1", "mocha": "^2.4.5", - "webpack": "^1.13.1" - }, - "dependencies": { - "backbone": "1.0.0", "react": "^15.3.0", "react-dom": "^15.3.0", - "underscore": "1.4.4" + "requirejs": "^2.1.1", + "underscore": "^1.4.4", + "webpack": "^1.13.1" } }