1

Adding code for accessibility

This commit is contained in:
Alex Yatskov 2015-01-05 15:10:10 +09:00
parent 7ad893571d
commit 01e7489bd3
4 changed files with 91 additions and 74 deletions

View File

@ -29,6 +29,7 @@ CREATE TABLE `keywords` (
`affordable` float NOT NULL, `affordable` float NOT NULL,
`atmospheric` float NOT NULL, `atmospheric` float NOT NULL,
`nearby` float NOT NULL, `nearby` float NOT NULL,
`access` float NOT NULL,
PRIMARY KEY (`name`) PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
@ -39,7 +40,7 @@ CREATE TABLE `keywords` (
LOCK TABLES `keywords` WRITE; LOCK TABLES `keywords` WRITE;
/*!40000 ALTER TABLE `keywords` DISABLE KEYS */; /*!40000 ALTER TABLE `keywords` DISABLE KEYS */;
INSERT INTO `keywords` VALUES ('accommodating',0,1,0,0,0),('affordable',0,0,1,0,0),('atmospheric',0,0,0,1,0),('delicious',1,0,0,0,0); INSERT INTO `keywords` VALUES ('accommodating',0,1,0,0,0,0),('affordable',0,0,1,0,0,0),('atmospheric',0,0,0,1,0,0),('delicious',1,0,0,0,0,0);
/*!40000 ALTER TABLE `keywords` ENABLE KEYS */; /*!40000 ALTER TABLE `keywords` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
@ -107,4 +108,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-01-05 14:32:39 -- Dump completed on 2015-01-05 15:09:00

View File

@ -1,5 +1,26 @@
#!/usr/bin/env node #!/usr/bin/env node
/*
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var mysql = require('mysql'); var mysql = require('mysql');
var data = require('./data.json'); var data = require('./data.json');
@ -38,18 +59,18 @@ for (var i = 0, count = data.length; i < count; ++i) {
// //
conn.query('DROP TABLE IF EXISTS keywords'); conn.query('DROP TABLE IF EXISTS keywords');
conn.query('CREATE TABLE keywords(name VARCHAR(50) NOT NULL, delicious FLOAT NOT NULL, accomodating FLOAT NOT NULL, affordable FLOAT NOT NULL, atmospheric FLOAT NOT NULL, nearby FLOAT NOT NULL, PRIMARY KEY(name))'); conn.query('CREATE TABLE keywords(name VARCHAR(50) NOT NULL, delicious FLOAT NOT NULL, accomodating FLOAT NOT NULL, affordable FLOAT NOT NULL, atmospheric FLOAT NOT NULL, nearby FLOAT NOT NULL, access FLOAT NOT NULL, PRIMARY KEY(name))');
var keywords = { var keywords = {
delicious: [1.0, 0.0, 0.0, 0.0, 0.0], delicious: [1.0, 0.0, 0.0, 0.0, 0.0, 0.0],
accommodating: [0.0, 1.0, 0.0, 0.0, 0.0], accommodating: [0.0, 1.0, 0.0, 0.0, 0.0, 0.0],
affordable: [0.0, 0.0, 1.0, 0.0, 0.0], affordable: [0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
atmospheric: [0.0, 0.0, 0.0, 1.0, 0.0] atmospheric: [0.0, 0.0, 0.0, 1.0, 0.0, 0.0]
}; };
for (var keyword in keywords) { for (var keyword in keywords) {
var record = keywords[keyword]; var record = keywords[keyword];
conn.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?, ?)', [keyword].concat(record)); conn.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?, ?, ?)', [keyword].concat(record));
} }

View File

@ -1,30 +1,25 @@
#!/usr/bin/env node #!/usr/bin/env node
/* /*
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
The MIT License (MIT) *
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Copyright (c) 2014 Alex Yatskov * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
Permission is hereby granted, free of charge, to any person obtaining a copy * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
of this software and associated documentation files (the "Software"), to deal * the Software, and to permit persons to whom the Software is furnished to do so,
in the Software without restriction, including without limitation the rights * subject to the following conditions:
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
copies of the Software, and to permit persons to whom the Software is * The above copyright notice and this permission notice shall be included in all
furnished to do so, subject to the following conditions: * copies or substantial portions of the Software.
*
The above copyright notice and this permission notice shall be included in * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
all copies or substantial portions of the Software. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
'use strict'; 'use strict';
@ -148,14 +143,15 @@ function addKeyword(query, callback) {
getKeywords(function(keywords) { getKeywords(function(keywords) {
var values = [ var values = [
query.keyword, query.keyword,
query.features.food, query.features.delicious,
query.features.service, query.features.accomodating,
query.features.value, query.features.affordable,
query.features.atmosphere, query.features.atmospheric,
query.features.proximity query.features.nearby,
query.features.accessible
]; ];
pool.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?, ?)', values, function(err) { pool.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?, ?, ?)', values, function(err) {
callback({ callback({
keyword: query.keyword, keyword: query.keyword,
success: err === null success: err === null
@ -183,11 +179,12 @@ function getKeywords(callback) {
for (var i = 0, count = rows.length; i < count; ++i) { for (var i = 0, count = rows.length; i < count; ++i) {
var row = rows[i]; var row = rows[i];
keywords[row.name] = { keywords[row.name] = {
food: row.food, delicious: row.delicious,
service: row.service, accomodating: row.accomodating,
value: row.value, affordable: row.affordable,
atmosphere: row.atmosphere, atmospheric: row.atmospheric,
proximity: row.proximity nearby: row.nearby,
accessible: row.access
}; };
} }
@ -206,15 +203,18 @@ function getRecords(geo, callback) {
name: row.name, name: row.name,
id: row.id, id: row.id,
relativeUrl: row.url, relativeUrl: row.url,
distanceToStation: row.distanceToStation,
geo: { geo: {
latitude: row.latitude, latitude: row.latitude,
longitude: row.longitude longitude: row.longitude
}, },
features: { features: {
food: row.food, delicious: row.delicious,
service: row.service, accomodating: row.accomodating,
value: row.value, affordable: row.affordable,
atmosphere: row.atmosphere atmospheric: row.atmospheric
}, },
}; };
}); });

View File

@ -1,30 +1,25 @@
#!/usr/bin/env node #!/usr/bin/env node
/* /*
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
The MIT License (MIT) *
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Copyright (c) 2014 Alex Yatskov * this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
Permission is hereby granted, free of charge, to any person obtaining a copy * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
of this software and associated documentation files (the "Software"), to deal * the Software, and to permit persons to whom the Software is furnished to do so,
in the Software without restriction, including without limitation the rights * subject to the following conditions:
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
copies of the Software, and to permit persons to whom the Software is * The above copyright notice and this permission notice shall be included in all
furnished to do so, subject to the following conditions: * copies or substantial portions of the Software.
*
The above copyright notice and this permission notice shall be included in * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
all copies or substantial portions of the Software. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
'use strict'; 'use strict';