Permalink
Browse files

finished with basic formatting shit

  • Loading branch information...
1 parent c89547f commit c5935f3fe835debce6fe6f1a896d38b646dc8f39 @shankj3 shankj3 committed Feb 17, 2017
Showing with 144 additions and 147 deletions.
  1. +11 −20 legis.py
  2. +0 −35 static/custom.css
  3. +0 −4 static/jquery.js
  4. +67 −6 static/what_happen.md
  5. +40 −0 static/whats_happenin.css
  6. +26 −82 templates/what_happen_md.html
View
@@ -1,6 +1,6 @@
-from flask import Flask, request, jsonify, render_template, Blueprint, flash, redirect, url_for
+from flask import Flask, request, render_template, Blueprint, flash, redirect, url_for
from flask_misaka import Misaka
-from flask_socketio import SocketIO
+from flask_socketio import SocketIO, emit
import requests
import requests_cache
import random
@@ -10,7 +10,7 @@
app = Flask(__name__)
-Misaka(app)
+Misaka(app, strikethrough=True, hard_wrap=True, wrap=True)
socketio = SocketIO(app)
app.secret_key = 'super secret key'
@@ -21,22 +21,13 @@
# cache for requests
requests_cache.install_cache('test_cache', backend='sqlite', expire_after=300)
-
-@app.route('/md_change', methods=['POST'])
-def md_change():
- print(request.data)
- return request.data
- # a = request.args.get('a', 0, type=int)
- # b = request.args.get('b', 0, type=int)
- # return jsonify(result=a + b)
-
-# todo: write changes to md_file after 10 minutes - avoid concurrency issues
-# @socketio.on('md change')
-# def md_change(data):
-# print('received json: ' + str(data))
-# md_change = open(vars.WHAT_WERE_DOING_MD, 'r+')
-# md_change.write(str(data))
-# md_change.close()
+# todo: add something special if two people connected at same time
+@socketio.on('md change')
+def md_change(data):
+ md_change = open(vars.WHAT_WERE_DOING_MD, 'r+')
+ md_change.write(str(data))
+ md_change.close()
+ emit('ACK', '')
@app.route('/')
def index():
@@ -51,7 +42,7 @@ def index():
def what_happen():
with open(vars.WHAT_WERE_DOING_MD, 'r') as f:
content = f.read()
- return render_template('what_happen_md.html', text=content)
+ return render_template('what_happen_md.html', text=content.strip())
@app.route('/my_reps', methods=['POST'])
def return_data():
View
@@ -64,39 +64,4 @@ article.legis-box {
div.finance-overview {
height: 15px;
-}
-
-.clear {
- clear:both;
-}
-
-
-html, body {
- height: 100%;
-}
-
-div#everything {
- height: 100%;
-}
-
-div#everything #textarea {
- float: left;
- width: 50%;
- max-width: 45%;
- padding: 10px;
- height: 100%;
- max-height: 100%;
-}
-
-div#everything #preview {
- float: right;
- width: 50%;
-}
-
-#textarea textarea#what_happen_text {
- /*max-width: 90%;*/
- width: 100%;
- max-width: 100%;
- height: 100%;
- max-height: 100%;
}
View
Oops, something went wrong.
View
@@ -1,6 +1,67 @@
-hello
-======
-*s
-*s
-
- dsf
+### Actively Working on
+
+_Make markdown page - MARIANNE_
+
+### Stuff we're thinking about
+
+Dynamic placement / scrolling of boxes so if the screen is small the contact info/committees/social media info doesn’t dwarf the picture and make the tile huge
+
+Possibly also get social media things for state reps?
+
+Make all boxes fixed height
+
+Add something that checks for invalid social media link before displaying - MARIANNE
+
+Separate bills into larger categories and display that instead
+(add to state level) bill breakdown
+
+how to differentiate between state vs. country level
+
+how to display title (State House/Senate/House of Representatives)
+
+Add actionables for contact information
+
+Display some sort of small game when pulling for data for the first time
+
+Make it so that candidates committees are in tab for ‘current term’
+
+Make it so that candidate committees are clickable
+
+Too long of text, limit text by box
+
+Fix financial data bug (look at what happens for Arizona senator)
+
+Display total money raised somewhere on rep tile
+
+How to make website faster
+Have requests cache, but need metrics
+
+HTML5 ASTEROIDS while you wait (Jessi talk to Mikey)
+
+We need a page to list our sources
+
+possibly make historical searches more accessible?
+
+### Stuff we thought about about and did
+
+~~Retrieve financial data for country level people - MARIANNE~~
+
+~~what to do about empty bills? --JESSI~~
+
+~~might be good to show state member historical roles since…some are….blank. Good to know they’re new or some shit? - JESSI~~
+
+~~Simple requests cache - JESSI~~
+
+~~make all the pictures the same size - MARIANNE~~
+
+~~Display committees for country level reps~~
+
+~~show social media buttons and link to them MARIANNE~~
+
+~~add default for no picture - MARIANNE~~
+
+~~Make homepage sexy - JESSI~~
+
+~~Validate homepage form - JESSI~~
+
+~~Display pretty graph for financial data for country level people - MARIANNE~~~~RIANNE~~~~
@@ -0,0 +1,40 @@
+.clear {
+ clear:both;
+}
+
+html, body {
+ height: 100%;
+ font-family: "Helvetica-Light";
+ background-color: #e1e1da;
+}
+
+div#everything {
+ height: 100%;
+}
+
+div#everything #textarea {
+ float: left;
+ width: 48%;
+ max-width: 48%;
+ padding: 10px;
+ height: 100%;
+ max-height: 100%;
+}
+
+div#everything #preview {
+ float: right;
+ width: 48%;
+ max-width: 48%;
+ padding: 0px 20px;
+ font-size: 1.1rem;
+ margin-bottom: 30px;
+}
+
+#textarea textarea#what_happen_text {
+ width: 100%;
+ max-width: 100%;
+ height: 100%;
+ padding: 10px;
+ font-size: 0.95rem;
+ font-family: "Courier New";
+}
@@ -3,23 +3,14 @@
<head>
<meta charset="UTF-8">
<title>See we're doing things</title>
- <link rel="stylesheet" href="{{ url_for('static', filename='custom.css') }}">
- <script type=text/javascript src="{{ url_for('static', filename='jquery.js') }}"></script>
+ <link rel="stylesheet" href="{{ url_for('static', filename='whats_happenin.css') }}">
</head>
-<script type=text/javascript>
- $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
-</script>
-
-<body>
+<body style="background-color:{{ background_color }};">
<div id="everything">
-
<div id="textarea">
- <textarea id="what_happen_text">
- {{ text }}
- </textarea>
+ <textarea id="what_happen_text">{{ text }}</textarea>
</div>
-
<div id="preview">
{{ text|markdown }}
</div>
@@ -29,79 +20,32 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.6.4/showdown.min.js"></script>
<script type="text/javascript">
- var change_count = 0;
-// var isConnected = false;
- var isDirty = false;
- var sentData = false;
-
- // on page load connect to websocket
-// var socket = io.connect('http://' + document.domain + ':' + location.port);
-// socket.on('connect', function() {
-// isConnected = true;
-// });
-
-
- var area = document.querySelector('textarea#what_happen_text');
- if (area.addEventListener) {
- area.addEventListener('input', function() {
-
- if (!isDirty) {
- isDirty = true;
- oldTime = new Date().getTime();
- }
-
- change_count = change_count + 1;
- console.log(change_count);
- var todo = document.getElementById("what_happen_text").value;
- if (change_count == 15) {
- send_md(todo);
- change_count = 0;
- oldTime = new Date().getTime();
- sentData = true;
- }
-
- }, false);
- } else if (area.attachEvent) {
- area.attachEvent('onpropertychange', function() {
- // IE-specific event handling code
- });
- }
-
+ var isConnected = false;
+ var converter = new showdown.Converter({
+ strikethrough: true,
+ simpleLineBreaks: true
+ });
+
+ var socket = io.connect('http://' + document.domain + ':' + location.port);
+ socket.on('connect', function() {
+ isConnected = true;
+ });
+
+ socket.on('ACK', function() {
+ converter.setOption('strikethrough', true);
+ var parsedHtml = converter.makeHtml(document.getElementById('what_happen_text').value);
+ document.getElementById("preview").innerHTML = parsedHtml;
+ });
+
+ //TODO: add text diff check before sending
setInterval(function() {
- if (!sentData && isDirty) {
- // todo: what happens after first call dirty-ing isdirty?
- var todo = document.getElementById("what_happen_text").value;
- send_md(todo);
- }
- }, 10000);
+ console.log('sent updates');
+ var todo = document.getElementById("what_happen_text").value;
+ send_md(todo.trim());
+ }, 5000);
function send_md(todo) {
- $.ajax({
- type : "POST",
- url : $SCRIPT_ROOT + '/md_change',
- data: todo,
- contentType: 'text;charset=UTF-8',
- success: function(result) {
-
-// console.log(micromarkdown.parse(result))
-// var input = document.getElementById('what_happen_text').value;
-// console.log('input', input)
-// var preview = document.getElementById('preview');
-// preview.innerHTML = micromarkdown.parse(input);
-// var test = $('#what_happen_text').html().replace(/\n/g, "\\n")
-
-
- var converter = new showdown.Converter(),
- text = $('#what_happen_text').val(),
- html = converter.makeHtml(text);
-// console.log(test);
- $('#preview').html(html);
- sendData = false;
- }
- });
-// if (isConnected) {
-// socket.emit('md change', todo);
-// }
+ if (isConnected) { socket.emit('md change', todo); }
}
</script>

0 comments on commit c5935f3

Please sign in to comment.