Compare commits
8 Commits
feedback-f
...
advanced-s
Author | SHA1 | Date | |
---|---|---|---|
4b90057664 | |||
90f49e7626 | |||
b015da2e9b | |||
9c6b57ba85 | |||
a080eebc29 | |||
323d7ce8ca | |||
da62a5c887 | |||
2714ad3e0c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
feedback_database.json
|
||||
config_centillion.py
|
||||
config_flask.py
|
||||
vp
|
||||
|
@@ -12,8 +12,13 @@ one centillion is 3.03 log-times better than a googol.
|
||||
## What Is It
|
||||
|
||||
Centillion (https://github.com/dcppc/centillion) is a search engine that can index
|
||||
three kinds of collections: Google Documents (.docx files), Github issues, and Markdown files in
|
||||
Github repos.
|
||||
different kinds of document collections: Google Documents (.docx files), Google Drive files,
|
||||
Github issues, Github files, Github Markdown files, and Groups.io email threads.
|
||||
|
||||
|
||||
|
||||
|
||||
## What Is It
|
||||
|
||||
We define the types of documents the centillion should index,
|
||||
what info and how. The centillion then builds and
|
||||
|
8
Todo.md
8
Todo.md
@@ -17,11 +17,13 @@ feedback form: where we are at
|
||||
- feedback button
|
||||
- button triggers modal form
|
||||
- modal has emojis for feedback, text box, buttons
|
||||
|
||||
feedback form: what we need to do
|
||||
- clicking emojis changes color, to select
|
||||
- clicking submit with filled out form submits to an endpoint
|
||||
- not sure how to use separate url, and then redirect back to same place
|
||||
- clicking submit also closes form, but only if submit successful
|
||||
|
||||
feedback form: what we need to do
|
||||
- fix alerts - thank you for your feedback doesn't show up until a refresh
|
||||
- probably an easy ajax fix
|
||||
|
||||
|
||||
|
||||
|
@@ -3,6 +3,7 @@ import subprocess
|
||||
|
||||
import codecs
|
||||
import os, json
|
||||
from datetime import datetime
|
||||
|
||||
from werkzeug.contrib.fixers import ProxyFix
|
||||
from flask import Flask, request, redirect, url_for, render_template, flash, jsonify
|
||||
@@ -266,16 +267,54 @@ def list_docs(doctype):
|
||||
search = Search(app.config["INDEX_DIR"])
|
||||
return jsonify(search.get_list(doctype))
|
||||
|
||||
# nope
|
||||
return render_template('403.html')
|
||||
|
||||
|
||||
@app.route('/feedback', methods=['POST'])
|
||||
def parse_request():
|
||||
data = request.get_json()
|
||||
flash("Thank you for your feedback!")
|
||||
with open('dumdumdumdeedum.json','w') as f:
|
||||
json.dumps(data,indent=4)
|
||||
|
||||
if not github.authorized:
|
||||
return redirect(url_for("github.login"))
|
||||
username = github.get("/user").json()['login']
|
||||
resp = github.get("/user/orgs")
|
||||
if resp.ok:
|
||||
all_orgs = resp.json()
|
||||
for org in all_orgs:
|
||||
if org['login']=='dcppc':
|
||||
|
||||
|
||||
try:
|
||||
# Business as usual
|
||||
data = request.form.to_dict();
|
||||
data['github_login'] = username
|
||||
data['timestamp'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
feedback_database = 'feedback_database.json'
|
||||
if not os.path.isfile(feedback_database):
|
||||
with open(feedback_database,'w') as f:
|
||||
json_data = [data]
|
||||
json.dump(json_data, f, indent=4)
|
||||
|
||||
else:
|
||||
json_data = []
|
||||
with open(feedback_database,'r') as f:
|
||||
json_data = json.load(f)
|
||||
|
||||
json_data.append(data)
|
||||
|
||||
with open(feedback_database,'w') as f:
|
||||
json.dump(json_data, f, indent=4)
|
||||
|
||||
## Should be done with Javascript
|
||||
#flash("Thank you for your feedback!")
|
||||
return jsonify({'status':'ok','message':'Thank you for your feedback!'})
|
||||
except:
|
||||
return jsonify({'status':'error','message':'An error was encountered while submitting your feedback. Try submitting an issue in the <a href="https://github.com/dcppc/centillion/issues/new">dcppc/centillion</a> repository.'})
|
||||
|
||||
|
||||
# nope
|
||||
return render_template('403.html')
|
||||
|
||||
@app.errorhandler(404)
|
||||
def oops(e):
|
||||
|
@@ -7,19 +7,127 @@
|
||||
// flask post data as json:
|
||||
// https://stackoverflow.com/a/16664376
|
||||
|
||||
/* make the smile green */
|
||||
/* this function is called when the user submits
|
||||
* the feedback form. it submits a post request
|
||||
* to the flask server, which squirrels away the
|
||||
* feedback in a file.
|
||||
*/
|
||||
function submit_feedback() {
|
||||
// this function is called when submit button clicked
|
||||
// algorithm:
|
||||
// - check if text box has content
|
||||
// - check if happy/sad filled out
|
||||
|
||||
var smile_active = $('#modal-feedback-smile-div').hasClass('smile-active');
|
||||
var frown_active = $('#modal-feedback-frown-div').hasClass('frown-active');
|
||||
if( !( smile_active || frown_active ) ) {
|
||||
alert('Please pick the smile or the frown.')
|
||||
} else if( $('#modal-feedback-textarea').val()=='' ) {
|
||||
alert('Please provide us with some feedback.')
|
||||
} else {
|
||||
var user_sentiment = '';
|
||||
if(smile_active) {
|
||||
user_sentiment = 'smile';
|
||||
} else {
|
||||
user_sentiment = 'frown';
|
||||
}
|
||||
var escaped_text = $('#modal-feedback-textarea').val();
|
||||
|
||||
// prepare form data
|
||||
var data = {
|
||||
sentiment : user_sentiment,
|
||||
content : escaped_text
|
||||
};
|
||||
// post the form. the callback function resets the form
|
||||
$.post("/feedback",
|
||||
data,
|
||||
function(response) {
|
||||
$('#myModal').modal('hide');
|
||||
$('#myModalForm')[0].reset();
|
||||
add_alert(response);
|
||||
frown_unclick();
|
||||
smile_unclick();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function add_alert(response) {
|
||||
str = ""
|
||||
str += '<div id="feedback-messages-container" class="container">';
|
||||
|
||||
if (response['status']=='ok') {
|
||||
// if status is ok, use alert-success
|
||||
str += ' <div id="feedback-messages-alert" class="alert alert-success alert-dismissible fade in">';
|
||||
} else {
|
||||
// otherwise use alert-danger
|
||||
str += ' <div id="feedback-messages-alert" class="alert alert-danger alert-dismissible fade in">';
|
||||
}
|
||||
|
||||
str += ' <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>';
|
||||
str += ' <div id="feedback-messages-contianer" class="container-fluid">';
|
||||
str += ' <div id="feedback-messages-div" class="co-xs-12">';
|
||||
str += ' <p>'
|
||||
str += response['message'];
|
||||
str += ' </p>';
|
||||
str += ' </div>';
|
||||
str += ' </div>';
|
||||
str += '</div>';
|
||||
$('div#messages').append(str);
|
||||
}
|
||||
|
||||
|
||||
/* for those particularly wordy users... limit feedback to 1000 chars */
|
||||
function cool_it() {
|
||||
if($('#modal-feedback-textarea').val().length > 1100 ){
|
||||
$('#modal-too-long').show();
|
||||
} else {
|
||||
$('#modal-too-long').hide();
|
||||
}
|
||||
}
|
||||
|
||||
/* smiley functions */
|
||||
function smile_click() {
|
||||
$('#modal-feedback-smile-div').addClass('smile-active');
|
||||
$('#modal-feedback-smile-icon').addClass('smile-active');
|
||||
}
|
||||
function frown_click() {
|
||||
$('#modal-feedback-frown-div').addClass('frown-active');
|
||||
$('#modal-feedback-frown-icon').addClass('frown-active');
|
||||
}
|
||||
function smile_unclick() {
|
||||
$('#modal-feedback-smile-div').removeClass('smile-active');
|
||||
$('#modal-feedback-smile-icon').removeClass('smile-active');
|
||||
}
|
||||
function frown_unclick() {
|
||||
$('#modal-feedback-frown-div').removeClass('frown-active');
|
||||
$('#modal-feedback-frown-icon').removeClass('frown-active');
|
||||
}
|
||||
|
||||
/* make the frown red */
|
||||
function frown_click() {
|
||||
$('#modal-feedback-smile-div').removeClass('smile-active');
|
||||
$('#modal-feedback-smile-icon').removeClass('smile-active');
|
||||
$('#modal-feedback-frown-div').addClass('frown-active');
|
||||
$('#modal-feedback-frown-icon').addClass('frown-active');
|
||||
function smile() {
|
||||
frown_unclick();
|
||||
smile_click();
|
||||
}
|
||||
function frown() {
|
||||
smile_unclick();
|
||||
frown_click();
|
||||
}
|
||||
|
||||
|
||||
/* for those particularly wordy users... limit feedback to 1100 chars */
|
||||
// how to check n characters in a textarea
|
||||
// https://stackoverflow.com/a/19934613
|
||||
/*
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#modal-feedback-textarea').on('change',function(event) {
|
||||
if($('#modal-feedback-textarea').val().length > 1100 ){
|
||||
$('#modal-too-long').show();
|
||||
} else {
|
||||
$('#modal-too-long').hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
@@ -1,3 +1,7 @@
|
||||
#modal-too-long {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* feedback smileys */
|
||||
#modal-feedback-smile-icon,
|
||||
#modal-feedback-frown-icon {
|
||||
|
25
templates/banner.html
Normal file
25
templates/banner.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<div class="container" id="banner-container">
|
||||
|
||||
{#
|
||||
banner image
|
||||
#}
|
||||
<div class="row" id="banner-row">
|
||||
<div class="col12sm" id="banner-col">
|
||||
<center>
|
||||
<a id="banner-a" href="{{ url_for('search')}}?query=&fields=">
|
||||
<img id="banner-img" src="{{ url_for('static', filename='centillion_white.png') }}">
|
||||
</a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
{% if config['TAGLINE'] %}
|
||||
<div class="row" id="tagline-row">
|
||||
<div class="col12sm" id="tagline-col">
|
||||
<center>
|
||||
<h2 id="tagline-tagline"> {{config['TAGLINE']}} </h2>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
14
templates/flashed_messages.html
Normal file
14
templates/flashed_messages.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div id="messages">
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div class="container" id="flashed-messages-container">
|
||||
<div class="alert alert-success alert-dismissible fade in">
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
{% for message in messages %}
|
||||
<p class="lead">{{ message }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
@@ -26,46 +26,15 @@
|
||||
|
||||
<div id="master-div">
|
||||
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div class="container" id="flashed-messages-container">
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
<ul class=flashes>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<div class="container" id="banner-container">
|
||||
{#
|
||||
flashed messages
|
||||
#}
|
||||
{% include "flashed_messages.html" %}
|
||||
|
||||
{#
|
||||
banner image
|
||||
#}
|
||||
<div class="row" id="banner-row">
|
||||
<div class="col12sm" id="banner-col">
|
||||
<center>
|
||||
<a id="banner-a" href="{{ url_for('search')}}?query=&fields=">
|
||||
<img id="banner-img" src="{{ url_for('static', filename='centillion_white.png') }}">
|
||||
</a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
{% if config['TAGLINE'] %}
|
||||
<div class="row" id="tagline-row">
|
||||
<div class="col12sm" id="tagline-col">
|
||||
<center>
|
||||
<h2 id="tagline-tagline"> {{config['TAGLINE']}} </h2>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% include "banner.html" %}
|
||||
|
||||
{#
|
||||
feedback modal
|
||||
@@ -73,6 +42,7 @@
|
||||
{% include "modal.html" %}
|
||||
|
||||
{% block body %}{% endblock %}
|
||||
|
||||
</div>
|
||||
|
||||
{% if active_page=="search" or active_page=="master_list" %}
|
||||
|
@@ -1,7 +1,10 @@
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
|
||||
<form id="myModalForm" method="post">
|
||||
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div id="myModal-content" class="modal-content">
|
||||
<div id="myModal-header" class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@@ -9,30 +12,40 @@
|
||||
Send us feedback!
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<div id="modal-feedback-smile-div" class="col-xs-6 text-center" onClick="smile_click()">
|
||||
<div id="myModal-body" class="modal-body">
|
||||
<div id="modal-feedback-smile-frown-container" class="container-fluid">
|
||||
<div id="modal-feedback-smile-div" class="col-xs-6 text-center"
|
||||
onClick="smile()">
|
||||
<i id="modal-feedback-smile-icon" class="fa fa-smile-o fa-4x" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div id="modal-feedback-frown-div" class="col-xs-6 text-center" onClick="frown_click()">
|
||||
<div id="modal-feedback-frown-div" class="col-xs-6 text-center"
|
||||
onClick="frown()">
|
||||
<i id="modal-feedback-frown-icon" class="fa fa-frown-o fa-4x" aria-hidden="true"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<p> </p>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div id="modal-feedback-textarea-container" class="container-fluid">
|
||||
<textarea id="modal-feedback-textarea" rows="6"></textarea>
|
||||
</div>
|
||||
<div id="modal-too-long" class="container-fluid" >
|
||||
<p id="modal-too-long-text" class="lead">Please limit the length of your feedback. Thank you in advance!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
<div id="myModal-footer" class="modal-footer">
|
||||
<div class="text-center">
|
||||
<button id="submit-feedback-btn" type="button" class="btn btn-lg btn-primary" data-dismiss="modal">
|
||||
<button id="submit-feedback-btn" type="button"
|
||||
onClick="submit_feedback()"
|
||||
class="btn btn-lg btn-primary">
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
@@ -10,12 +10,15 @@
|
||||
<form action="{{ url_for('search') }}" name="search">
|
||||
<p><input type="text" name="query" value="{{ query }}">
|
||||
</p>
|
||||
<p><button id="the-big-one" type="submit" style="font-size: 20px; padding: 10px; padding-left: 50px; padding-right: 50px;"
|
||||
<p><button id="the-big-one" type="submit"
|
||||
style="font-size: 20px; padding: 10px; padding-left: 50px; padding-right: 50px;"
|
||||
value="search" class="btn btn-primary">Search</button>
|
||||
</p>
|
||||
|
||||
<p><a href="#" onClick="advanced_search()">[Advanced Search]</a>
|
||||
|
||||
{% if parsed_query %}
|
||||
<p><a href="{{ url_for('search')}}?query=&fields=">[clear all results]</a>
|
||||
<p><a href="{{ url_for('search')}}?query=&fields=">[Clear All Results]</a>
|
||||
{% endif %}
|
||||
|
||||
</p>
|
||||
@@ -25,6 +28,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="height: 20px;"><p> </p></div>
|
||||
|
||||
<div id="info-bars-container" class="container">
|
||||
<div class="row">
|
||||
|
||||
|
Reference in New Issue
Block a user