-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement getData and data structure >relates #28
- Loading branch information
Showing
8 changed files
with
252 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
<!-- This is the terminal snapshot of steps of initial bower/? css install steps after git pull--> | ||
``` | ||
Nanis-MacBook-Air:tech-access ssun2$ git checkout -b css-works | ||
Switched to a new branch 'css-works' | ||
Nanis-MacBook-Air:tech-access ssun2$ npm i | ||
audited 20040 packages in 7.338s | ||
found 0 vulnerabilities | ||
Nanis-MacBook-Air:tech-access ssun2$ npm install -g bower | ||
npm WARN deprecated [email protected]: We don't recommend using Bower for new projects. Please consider Yarn and Webpack or Parcel. You can read how to migrate legacy project here: https://bower.io/blog/2017/how-to-migrate-away-from-bower/ | ||
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower | ||
+ [email protected] | ||
added 1 package from 1 contributor in 3.795s | ||
Nanis-MacBook-Air:tech-access ssun2$ ls | ||
Documents config.env database package-lock.json public | ||
README.md coverage node_modules package.json src | ||
Nanis-MacBook-Air:tech-access ssun2$ cd public/stylesheets | ||
Nanis-MacBook-Air:stylesheets ssun2$ ls | ||
bower.json main.css main.css.map main.scss | ||
Nanis-MacBook-Air:stylesheets ssun2$ bower install | ||
bower o-grid#^4.4.3 not-cached https://github.com/Financial-Times/o-grid.git#^4.4.3 | ||
bower o-grid#^4.4.3 resolve https://github.com/Financial-Times/o-grid.git#^4.4.3 | ||
bower o-grid#^4.4.3 download https://github.com/Financial-Times/o-grid/archive/v4.4.3.tar.gz | ||
bower o-grid#^4.4.3 extract archive.tar.gz | ||
bower o-grid#^4.4.3 resolved https://github.com/Financial-Times/o-grid.git#4.4.3 | ||
bower sass-mq#^5.0.0 not-cached https://github.com/sass-mq/sass-mq.git#^5.0.0 | ||
bower sass-mq#^5.0.0 resolve https://github.com/sass-mq/sass-mq.git#^5.0.0 | ||
bower sass-mq#^5.0.0 download https://github.com/sass-mq/sass-mq/archive/v5.0.0.tar.gz | ||
bower sass-mq#^5.0.0 extract archive.tar.gz | ||
bower sass-mq#^5.0.0 resolved https://github.com/sass-mq/sass-mq.git#5.0.0 | ||
bower o-grid#^4.4.3 install o-grid#4.4.3 | ||
bower sass-mq#^5.0.0 install sass-mq#5.0.0 | ||
o-grid#4.4.3 bower_components/o-grid | ||
└── sass-mq#5.0.0 | ||
sass-mq#5.0.0 bower_components/sass-mq | ||
Nanis-MacBook-Air:stylesheets ssun2$ sass --watch main.scss main.css | ||
File main.css is a CSS file. | ||
Did you mean: sass --watch main.scss:main.css | ||
Use --trace for backtrace. | ||
Nanis-MacBook-Air:stylesheets ssun2$ sass --watch main.scss:main.css | ||
>>> Sass is watching for changes. Press Ctrl-C to stop. | ||
error bower_components/o-grid/main.scss (Line 7: File to import not found or unreadable: sass-mq/mq.) | ||
>>> Change detected to: bower_components/o-grid/main.scss | ||
write main.css | ||
write main.css.map | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
exports.get = (req, res) => { | ||
res.render('home', {activePage:{home: true}}) | ||
res.render('home2', {activePage:{home2: true}}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
exports.get = (req, res) => { | ||
res.render('resources', { | ||
layout: 'scrollable' | ||
}); | ||
} | ||
|
||
exports.get = (req, res) => { | ||
res.render('resources', { | ||
layout: 'scrollable' | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const queries = require('../model/index'); | ||
//implement form=post in frontend | ||
exports.post = (req, response) => { | ||
//get params, demo_tags is array | ||
//const {demo_tags} = req.body; | ||
const demo_tags = ['age', 'disability', 'gender']; | ||
queries.getData(demo_tags) | ||
.then((res) => { | ||
//Pure function?? | ||
const userDemoTag = res.rows; | ||
const resultArray = arrangeArray(userDemoTag); | ||
const outArray = filterByType(resultArray); | ||
console.log('OUTARRAY', outArray); | ||
//const resultArray = (res.rows); | ||
|
||
// console.log('AFTER', resultArray); | ||
|
||
response.render('results', { outArray }); | ||
}) | ||
.catch(err => console.log(err)); | ||
//to arrange as ['meetup'= [{},{},...], 'classroom_course'= [{},{},...], 'article'=[{},{},...],.....] | ||
function filterByType(inArray) { | ||
const types = ['meetup', 'online course', 'article', 'classroom course']; | ||
const outArr = [] | ||
types.forEach(mytype => { | ||
//outArr[meetup]= filtered result// setting keys to values from filter function | ||
outArr[mytype] = inArray.filter(function (value) { | ||
return value.resource_type == mytype; | ||
}) | ||
}) | ||
return outArr; | ||
} | ||
|
||
//to arrange repeated resource as {resource_id='1', resource_name='codebar', direct=['age','ethnicity'], indirect=['disability']},.... | ||
function arrangeArray(inArray) { | ||
var resultArray = []; //empty array to start with | ||
for (let i = 0; i < inArray.length; i++) { | ||
if (i == 0) { | ||
//populate new resouce in our result array | ||
resultArrIndx = 0; | ||
// resultArray.push({inArray[i].resource_id, inArray[i].resource_name, inArray[i].url}); | ||
resultArray.push({ | ||
resource_id: inArray[i].resource_id, resource_name: inArray[i].resource_name, | ||
url: inArray[i].url, resource_type: inArray[i].resource_type | ||
}); | ||
|
||
resultArray[resultArrIndx].direct = []; | ||
resultArray[resultArrIndx].indirect = []; | ||
//if incoming demo_tag_relevance is direct push it into resultArray[resultArrIndx].direct array else | ||
//push into resultArray[resultArrIndx].indirect array | ||
if (inArray[i].relevance === 'direct') { | ||
resultArray[resultArrIndx].direct.push(inArray[i].tag_name); | ||
} else { | ||
resultArray[resultArrIndx].indirect.push(inArray[i].tag_name); | ||
} | ||
resultArrIndx++; | ||
// resultArray[resultArrIndx].demo_tag_relevance = []; | ||
// const b = {}; | ||
// b.tag_name = inArray[i].tag_name; | ||
// b.relevance = inArray[i].relevance; | ||
// resultArray[resultArrIndx].demo_tag_relevance.push(b); | ||
|
||
// console.log('RESULTARRAY AFTER', resultArray); | ||
} | ||
else if (resultArray[resultArrIndx - 1].resource_id == inArray[i].resource_id) { | ||
//console.log('PROBLEM', inArray[i].relevance) | ||
// resultArray[resultArrIndx - 1].demo_tag_relevance.push({ 'tag_name': inArray[i].tag_name, 'relevance': inArray[i].relevance }); | ||
if (inArray[i].demo_tag_relevance === 'direct') { | ||
|
||
resultArray[resultArrIndx - 1].direct.push(inArray[i].tag_name); | ||
} else { | ||
resultArray[resultArrIndx - 1].indirect.push(inArray[i].tag_name); | ||
} | ||
} | ||
else { | ||
//populate new resouce in our result array | ||
//create new key demo_tag_relevance and push {tagname:'tagname value', relevance:'rel value'} | ||
resultArray.push({ | ||
resource_id: inArray[i].resource_id, resource_name: inArray[i].resource_name, | ||
url: inArray[i].url, resource_type: inArray[i].resource_type | ||
}); | ||
resultArray[resultArrIndx].direct = []; | ||
resultArray[resultArrIndx].indirect = []; | ||
//if incoming demo_tag_relevance is direct push it into resultArray[resultArrIndx].direct array else | ||
//push into resultArray[resultArrIndx].indirect array | ||
if (inArray[i].relevance === 'direct') { | ||
resultArray[resultArrIndx].direct.push(inArray[i].tag_name); | ||
} else { | ||
resultArray[resultArrIndx].indirect.push(inArray[i].tag_name); | ||
} | ||
resultArrIndx++; | ||
} | ||
|
||
} //eof for | ||
// console.log('resultArray =', resultArray); | ||
// resultArray[2].demo_tag_relevance.forEach(function (officer) { | ||
// console.log(officer.tag_name, ":", officer.relevance); | ||
//}) | ||
|
||
return resultArray; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>tech-access</title> | ||
</head> | ||
<body> | ||
<nav> | ||
<h2>Tech Access App</h2> | ||
</nav> | ||
<figure> | ||
<img src="/images/unsplashpeoplecoding.jpeg" alt="diverse people coding" width:"200" height:"200"> | ||
</figure> | ||
|
||
</body> | ||
|
||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{!-- | ||
<h3>Meetups</h3> --}} | ||
<ul> | ||
{{#each outArray.meetup}} | ||
<li>{{this.resource_name}} {{this.resource_type}}</li> | ||
{{/each}} | ||
</ul> | ||
|
||
<ul> | ||
{{#each outArray.article}} | ||
<li>{{this.resource_name}} {{this.resource_type}}</li> | ||
{{/each}} | ||
</ul> | ||
|
||
|
||
<ul> | ||
{{#each outArray.[classroom course]}} | ||
<li>{{this.resource_name}} {{this.resource_type}}</li> | ||
{{/each}} | ||
</ul> | ||
|
||
<ul> | ||
{{#each outArray.[online course] }} | ||
<li>{{this.resource_name}} {{this.resource_type}}</li> | ||
{{/each}} | ||
</ul> |