Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Parliament/client/stylesheets/
17 changes: 17 additions & 0 deletions OtherResources/wikiparse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from bs4 import BeautifulSoup
import wikipedia
import requests
import urllib

class Article(object):
"""Represents a wikipedia article"""
def __init__(self, title):
if not title:
raise Exception

url = urllib.quote(title)
url = "http://en.wikipedia.org/wiki/"+url
html = requests.get(url)
soup = BeautifulSoup(html)


1 change: 1 addition & 0 deletions Parliament/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
17 changes: 17 additions & 0 deletions Parliament/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

standard-app-packages
coffeescript
stylus
jade
less
less-bootstrap-3
font-awesome-4-less
accounts-ui
iron-router
collection2
pen
accounts-google
1 change: 1 addition & 0 deletions Parliament/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.8.2
124 changes: 124 additions & 0 deletions Parliament/client/ParlClient.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
Requests = new Meteor.Collection 'requests'
Queries = new Meteor.Collection 'queries'
Responses = new Meteor.Collection 'responses'

Router.onBeforeAction 'loading'

Router.map ->
this.route 'home',
path: '/'
waitOn: -> Meteor.subscribe 'latest'
data:
latest: Queries.find {}, {sort: [['created', 'desc'], 'query']}
this.route 'create'
this.route 'tag',
path: '/tagged/:tag'
waitOn: -> Meteor.subscribe 'tagged', decodeURI this.params.tag
data: ->
tag = this.params.tag
return {
tag: decodeURI tag
queries: Queries.find {}, {sort: [['created', 'desc'], 'query']}
}
this.route 'query',
path: '/queries/:_id'
waitOn: ->
Meteor.subscribe 'query', this.params._id
Meteor.subscribe 'responses', this.params._id
Meteor.subscribe 'queryRequest', this.params._id
data: ->
id = this.params._id
dict =
query: Queries.findOne id
responses: Responses.find {}
request: Requests.findOne {queries: id}
return dict
this.route 'request',
path: '/requests/:_id'
waitOn: ->
Meteor.subscribe 'request', this.params._id
Meteor.subscribe 'requestQueries', this.params._id
Meteor.subscribe 'requestResponses', this.params._id
data: ->
id = this.params._id
dict = Requests.findOne id
return dict
this.route 'me',
path: '/me'
waitOn: ->
Meteor.subscribe 'userSelf'

Template.intro.events
'click #create': ->
Router.go 'create'

Template.create.events
'click #submit': (event, template) ->
jhtml = template.$('.pen')
html = jhtml.html()
queryArray = (query.innerText for query in jhtml.find('u').get())
text = jhtml.text()
topic = template.find('#topic').value
comment = template.find('#comment').value
tags = template.find('#tags').value.split(/\s*,\s*/)
Meteor.call 'addQuery', topic, queryArray, tags, comment, text, html
Router.go 'home'

Template.navbar.events
'submit form#tagsearch': (event, template) ->
term = template.find('#searchfield').value
term = encodeURI(term)
Router.go 'tag',
tag: term
'click a.userPage': (event, template) ->
Router.go 'me'

Template.query.events
'click button#add': (event, template) ->
jhtml = template.$('.pen')
html = jhtml.html()
id = this.query._id
# id = Queries.findOne({})._id
Meteor.call 'queryRespond', id, html
template.$('.pen').html('')
'click button.up': (event, template) ->
id = this._id
Meteor.call 'upvote', id
'click button.down': (event, template) ->
id = this._id
Meteor.call 'downvote', id

Template.request.events
'click u': (event, template) ->
name = event.currentTarget.innerText
id = Queries.findOne({query: name})._id
top = Responses.findOne {query: id},
sort: [['votes', 'desc'], ['created', 'desc']]
console.log this
Session.set 'topResponse', top
$('#explanation').modal 'show'
'click button.close': (event, template) ->
$('#explanation').modal 'hide'

Template.explanation.helpers
topResponse: ->
return Session.get 'topResponse'

Template.create.rendered = ->
this._editor = new Pen('#editor')

Template.create.destroyed = ->
this._editor.destroy

Template.query.rendered = ->
this._editor = new Pen('#editor')

Template.query.destroyed = ->
this._editor.destroy

Template.explanation.rendered = ->
$('#explanation').modal
show: false

Template.explanation.destroyed = ->
$('#explanation').modal 'hide'
34 changes: 34 additions & 0 deletions Parliament/client/templates/create.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
template(name='create')
if currentUser
+createForm
else
.container
.row
.panel.panel-default
.panel-body
h2 Please log in to submit a question:
+loginButtons

template(name='createForm')
.container
.row
.col-xs-12
h1 Create a query:
br
.row
.col-md-8.col-md-offset-1
form
.form-group
label The specific topic of this query:
input(type='text' placeholder='Enter the topic').form-control#topic
.form-group
label Paste in the source you're using. Highlight any phrases that need clarification by selecting the text and clicking the underline button:
.form-control#editor
.form-group
label A brief comment on why you're confused:
textarea.form-control#comment(rows='7' placeholder="Comment on what's confusing you")
.form-group
label Tags, keep them general so people can find your query:
input(type='text' placeholder='Enter comma-separated tags').form-control#tags
.form-group
button.btn.btn-success.pull-right.btn-lg#submit(type='button') Submit
38 changes: 38 additions & 0 deletions Parliament/client/templates/index.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
head
title Parliament
body
+navbar

template(name='home')
+intro
+latest

template(name='intro')
.jumbotron
.container
h1 Parliament
p is a cool thing that lets you make queries to simplify a body of information into a learnable format
button#create.btn.btn-primary.btn-lg Create a query!


template(name='latest')
.container
.row
.panel.panel-default
.panel-heading
h2 Latest Queries
table.table
thead
tr
th Query
th Topic
th Tags
tbody
each latest
tr
td
a(href="{{pathFor 'query'}}") #{query}
td
a(href="{{pathFor 'request' _id=this.request}}") #{topic}
td.tagcol
+tagbox
5 changes: 5 additions & 0 deletions Parliament/client/templates/misc.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
template(name='loading')
.container
.row
.col-xs-12
h2 Loading...
40 changes: 40 additions & 0 deletions Parliament/client/templates/navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template name='navbar'>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ pathFor 'home' }}">Parliament</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ pathFor 'create' }}">Create</a></li>
{{#if currentUser}}
<li><a class="userPage">Me</a></li>
{{/if}}
</ul>
<form class="navbar-form navbar-left" role="search" id="tagsearch">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search for a query tag" id="searchfield">
</div>
<button type="submit" class="btn btn-default" id='searchsubmit'>Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<div class='pull-right'>
<div class='login'>
{{>loginButtons}}
</div>
</div>
<!-- RIGHT LINKS HERE -->
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</template>
52 changes: 52 additions & 0 deletions Parliament/client/templates/query.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
template(name='query')
.container
.row
h2 Explain #{query.query} from this material on #{query.topic}:
with request
.row
.panel.panel-default
.panel-body !{html}
.panel-body
p #{comment}
.panel-body
+tagbox
.row
if responses.count
h3 Here are some proposed explanations for the topic:
else
h3 There are no explanations yet. Write your own!
each responses
.row
img(src="{{createdBy.image}}").img-circle.userThumb.inline
div.inline.namevote
h3 #{createdBy.name} says:
.btn-group
if currentUser
button.btn.btn-danger.down
span.glyphicon.glyphicon-chevron-down
.btn.btn-default(disabled) #{votes}
button.btn.btn-success.up
span.glyphicon.glyphicon-chevron-up
else
button.btn.btn-danger.down(disabled)
span.glyphicon.glyphicon-chevron-down
.btn.btn-default(disabled) #{votes}
button.btn.btn-success.up(disabled)
span.glyphicon.glyphicon-chevron-up
.panel.panel-default
.panel-body !{response}
.row
if responses.count
h3 Add a response of your own:
if currentUser
form
.panel.panel-default
.panel-body
.form-control#editor
.panel-footer
button.btn.btn-success(type="button")#add Add this response
else
.panel.panel-default
.panel-body
h2 Please log in to submit a response:
+loginButtons
21 changes: 21 additions & 0 deletions Parliament/client/templates/request.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
template(name='request')
.container
.row
h2 #{name}
.panel.panel-default
.panel-body !{html}
.panel-body
p #{comment}
.panel-body
+tagbox
+explanation

template(name='explanation')
.modal.fade#explanation(tabindex='-1')
.modal-dialog.modal-sm
.modal-content
.modal-header
button.close(type='button')
span(aria-hidden='true') &times;
with topResponse
.modal-body !{response}
25 changes: 25 additions & 0 deletions Parliament/client/templates/tag.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
template(name='tag')
.container
.row
.panel.panel-default
.panel-heading
h2 Queries tagged #{tag}:
table.table
thead
tr
th Query
th Topic
th Tags
tbody
each queries
tr
td #{query}
td #{topic}
td.tagcol
+tagbox

template(name='tagbox')
.tagbox
each tags
a(href="{{pathFor 'tag' tag=this}}")
button.btn.btn-default.btn-sm #{this}
4 changes: 4 additions & 0 deletions Parliament/client/templates/users.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template(name="me")
.container
.row
h1 Nothing here yet
Loading