-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raj Singh
committed
Dec 8, 2016
1 parent
0eb157e
commit 755009a
Showing
6 changed files
with
104 additions
and
39 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
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,27 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var request = require('request'); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
var relurl = "https://api.stackexchange.com/2.2/similar?"; | ||
relurl += "order=desc&sort=relevance&site=stackoverflow"; | ||
relurl += "&title=" + encodeURIComponent(req.query.title); | ||
if (req.query.tags) relurl += "&tags=" + req.query.tags; | ||
// relurl = "http://localhost:3000/test.json"; | ||
console.log("relurl: "+relurl); | ||
|
||
request({url:relurl, json:true, gzip:true}, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
// pass data to view | ||
console.log("GOT GOOD BODY:"); | ||
console.log(body); | ||
res.render('related', { relatedqs: body, title: req.query.title }); | ||
} else { | ||
res.send("Couldn't get Stackoverflow related questions:\n"+error); | ||
} | ||
}) | ||
|
||
}); | ||
|
||
module.exports = router; |
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,44 +1,45 @@ | ||
extends layout | ||
|
||
block content | ||
div.container | ||
div.row | ||
div.col.s12 | ||
h1 Stackoverflow Status | ||
div.row | ||
div.col.s12 | ||
h5.subhead Questions without an accepted answer, tagged any of: | ||
|
||
h5.subhead Questions without an accepted answer, tagged any of: | ||
- var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; | ||
- var searchwords = search.split(',').map(Function.prototype.call, String.prototype.trim); | ||
p | ||
each w in searchwords | ||
a.so-tag.waves-effect.waves-light.btn.blue(onclick='javascript:toggleTagVisibility(this)')= w | ||
hr | ||
|
||
- var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; | ||
- var searchwords = search.split(',').map(Function.prototype.call, String.prototype.trim); | ||
p | ||
each w in searchwords | ||
a.so-tag.waves-effect.waves-light.btn.blue(onclick='javascript:toggleTagVisibility(this)')= w | ||
hr | ||
div.row.so-questions | ||
each q in questions | ||
- qdate = new Date(q.value.creation_date * 1000) | ||
- qprettydate = qdate.getDate() + ' ' + monthNames[qdate.getMonth()] + ' ' + qdate.getFullYear(); | ||
|
||
div.row.so-questions | ||
each q in questions | ||
- qdate = new Date(q.value.creation_date * 1000) | ||
- qprettydate = qdate.getDate() + ' ' + monthNames[qdate.getMonth()] + ' ' + qdate.getFullYear(); | ||
- relurl = "/related?title=" + q.value.title + "&tags=" | ||
each tag in q.value.tags | ||
- relurl += tag + ";" | ||
|
||
div.col.s12.m6.l4.questioncol.notdisplayed | ||
div.card.sticky-action.small.question.z-depth-4 | ||
div.card-content | ||
i.material-icons.right.activator(role="button")= "more_vert" | ||
h5.activator.questiontitle | ||
:verbatim !{q.value.title} | ||
p.grey-text.date= qprettydate | ||
hr.blue-text | ||
div.tags | ||
each tag in q.value.tags | ||
span.tag.chip.small.blue= tag.toString() | ||
div.card-action | ||
a.pink-text(href=q.value.link, target="_blank" title="View on SO") | ||
i.material-icons.small= "open_in_browser" | ||
span.answercount.badge.right.white-text.pink(title="answers")= q.value.answer_count | ||
div.card-reveal | ||
span.card-title.grey-text= "Details" | ||
i.material-icons.right(role="button")= "close" | ||
div.grey-text | ||
:verbatim !{q.value.body} | ||
|
||
|
||
div.col.s12.m6.l4.questioncol.notdisplayed | ||
div.card.sticky-action.small.question.z-depth-4 | ||
div.card-content | ||
i.material-icons.right.activator(role="button")= "more_vert" | ||
h5.activator.questiontitle | ||
:verbatim !{q.value.title} | ||
p.grey-text.date= qprettydate | ||
hr.blue-text | ||
div.tags | ||
each tag in q.value.tags | ||
span.tag.chip.small.blue= tag.toString() | ||
div.card-action | ||
a.pink-text(href=q.value.link, target="_blank" title="View on SO") | ||
i.material-icons.small= "open_in_browser" | ||
a.pink-text(href=relurl, title="Related questions") | ||
i.material-icons.small= "question_answer" | ||
span.answercount.badge.right.white-text.pink(title="answers")= q.value.answer_count | ||
div.card-reveal | ||
span.card-title.grey-text= "Details" | ||
i.material-icons.right(role="button")= "close" | ||
div.grey-text | ||
:verbatim !{q.value.body} |
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,26 @@ | ||
extends layout | ||
|
||
block content | ||
div.row | ||
div.col.s12 | ||
div= "Questions related to:" | ||
h5.subhead= title | ||
|
||
hr | ||
|
||
div.row.so-related | ||
each q in relatedqs.items | ||
div.col.s12.m6.l4.relcol | ||
div.card.small.z-depth-4.relq | ||
div.card-content | ||
h5.questiontitle | ||
a(href=q.link, target="_blank" title="View on SO") | ||
:verbatim !{q.title} | ||
div.tags | ||
each tag in q.tags | ||
span.tag.chip.small.grey= tag.toString() | ||
div.card-action | ||
a.pink-text(href=q.link, target="_blank" title="View on SO") | ||
i.material-icons.small= "open_in_browser" | ||
span.answercount.badge.right.white-text.pink(title="answers")= q.answer_count | ||
|