Browse Source

it's a banner

ansible-setup-and-deploy
Alex 6 years ago
parent
commit
eb42380c96
  1. 13
      app/models.py
  2. 176
      app/static/js/app.js
  3. 2377
      app/static/js/bootstrap.js
  4. 7
      app/static/js/bootstrap.min.js
  5. 32
      app/templates/base.html
  6. 5
      app/templates/home.html
  7. 16
      app/views.py

13
app/models.py

@ -56,6 +56,19 @@ class Author(db.Model):
def __init__(self, author_name):
self.author_name = author_name
class UserIns(db.Model):
__tablename__ = 'userins'
id = db.Column(db.Integer(), primary_key=True)
title = db.Column(db.String(500))
info = db.Column(db.String(500))
def __init__(self, title, info):
self.title = title
self.info = info
class Stack(db.Model):
__tablename__ = 'stacks'
id = db.Column(db.Integer, primary_key = True)

176
app/static/js/app.js

@ -1,122 +1,126 @@
/* Add your Application JavaScript */
$(function() {
$("div[data-toggle=fieldset]").each(function() {
var $this = $(this);
//Add new entry
$this.find("button[data-toggle=fieldset-add-row]").click(function() {
var target = $($(this).data("target"))
console.log(target);
var oldrow = target.find("[data-toggle=fieldset-entry]:last");
var row = oldrow.clone(true, true);
console.log(row.find(":input")[0]);
var elem_id = row.find(":input")[0].id;
var elem_num = parseInt(elem_id.replace(/.*-(\d{1,4})-.*/m, '$1')) + 1;
row.attr('data-id', elem_num);
row.find(":input").each(function() {
console.log(this);
var id = $(this).attr('id').replace('-' + (elem_num - 1) + '-', '-' + (elem_num) + '-');
$(this).attr('name', id).attr('id', id).val('').removeAttr("checked");
});
oldrow.after(row);
}); //End add new entry
//Remove row
$this.find("button[data-toggle=fieldset-remove-row]").click(function() {
if($this.find("[data-toggle=fieldset-entry]").length > 1) {
var thisRow = $(this).closest("[data-toggle=fieldset-entry]");
thisRow.remove();
}
}); //End remove row
});
$("div[data-toggle=fieldset]").each(function() {
var $this = $(this);
//Add new entry
$this.find("button[data-toggle=fieldset-add-row]").click(function() {
var target = $($(this).data("target"))
console.log(target);
var oldrow = target.find("[data-toggle=fieldset-entry]:last");
var row = oldrow.clone(true, true);
console.log(row.find(":input")[0]);
var elem_id = row.find(":input")[0].id;
var elem_num = parseInt(elem_id.replace(/.*-(\d{1,4})-.*/m, '$1')) + 1;
row.attr('data-id', elem_num);
row.find(":input").each(function() {
console.log(this);
var id = $(this).attr('id').replace('-' + (elem_num - 1) + '-', '-' + (elem_num) + '-');
$(this).attr('name', id).attr('id', id).val('').removeAttr("checked");
});
oldrow.after(row);
}); //End add new entry
//Remove row
$this.find("button[data-toggle=fieldset-remove-row]").click(function() {
if ($this.find("[data-toggle=fieldset-entry]").length > 1) {
var thisRow = $(this).closest("[data-toggle=fieldset-entry]");
thisRow.remove();
}
}); //End remove row
});
});
$( function() {
$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
$(function() {
$("#draggable").draggable();
$("#droppable").droppable({
drop: function(event, ui) {
$(this)
.addClass("ui-state-highlight")
.find("p")
.html("Dropped!");
}
});
} );
});
$( "#title" ).click(function() {
$("#title").click(function() {
generateTitle(this);
});
$( document ).ready(function() {
$(document).ready(function() {
generateTitle("#title");
});
function generateTitle(elem){
var x = ["XPERIMENTAL"]
var p1 = ["POTENTIAL", "PUBLIC", "POST", "PI", "PLATFORM FOR", "PRETENTIOUS"]
var p2 = ["PIRATE", "PERFORMATIVE", "PUBLIC", "PUBLISHING", "POTENTIAL"]
var l = ["LIBRARY", "LIAISON", "LAB", "LEGALITY", "LABOUR"]
function generateTitle(elem) {
var x = ["XPERIMENTAL"]
var p1 = ["POTENTIAL", "PUBLIC", "POST", "PI", "PLATFORM FOR", "PRETENTIOUS"]
var p2 = ["PIRATE", "PERFORMATIVE", "PUBLIC", "PUBLISHING", "POTENTIAL"]
var l = ["LIBRARY", "LIAISON", "LAB", "LEGALITY", "LABOUR"]
$(elem).text(x[Math.floor(Math.random()*x.length)]+" "+p1[Math.floor(Math.random()*p1.length)]+" "+p2[Math.floor(Math.random()*p2.length)]+" "+l[Math.floor(Math.random()*l.length)]);
$(elem).text(x[Math.floor(Math.random() * x.length)] + " " + p1[Math.floor(Math.random() * p1.length)] + " " + p2[Math.floor(Math.random() * p2.length)] + " " + l[Math.floor(Math.random() * l.length)]);
}
$( function() {
$( "#tabs" ).tabs().addClass( "ui-tabs-vertical ui-helper-clearfix" );
$( "#tabs li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" );
} );
$(function() {
$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
});
var marquee = $('div.marquee');
marquee.each(function() {
var mar = $(this),indent = mar.width();
mar.marquee = function() {
indent--;
mar.css('text-indent',indent);
if (indent < -1 * mar.children('div.marquee-text').width()) {
indent = mar.width();
}
};
mar.data('interval',setInterval(mar.marquee,1000/60));
});
$( ".no_cover" ).each(function() {
$(".no_cover").each(function() {
var string = $(this).attr('id')
var randomColor = colorHash(string).rgb
$(this).css({
'background-color' : randomColor,
'background-color': randomColor,
});
}
)
})
function colorHash(inputString){
var sum = 0;
function colorHash(inputString) {
var sum = 0;
for(var i in inputString){
sum += inputString.charCodeAt(i);
}
for (var i in inputString) {
sum += inputString.charCodeAt(i);
}
r = ~~(('0.'+Math.sin(sum+1).toString().substr(6))*256);
g = ~~(('0.'+Math.sin(sum+2).toString().substr(6))*256);
b = ~~(('0.'+Math.sin(sum+3).toString().substr(6))*256);
r = ~~(('0.' + Math.sin(sum + 1).toString().substr(6)) * 256);
g = ~~(('0.' + Math.sin(sum + 2).toString().substr(6)) * 256);
b = ~~(('0.' + Math.sin(sum + 3).toString().substr(6)) * 256);
var rgb = "rgb("+r+", "+g+", "+b+")";
var rgb = "rgb(" + r + ", " + g + ", " + b + ")";
var hex = "#";
var hex = "#";
hex += ("00" + r.toString(16)).substr(-2,2).toUpperCase();
hex += ("00" + g.toString(18)).substr(-2,2).toUpperCase();
hex += ("00" + b.toString(20)).substr(-2,2).toUpperCase();
hex += ("00" + r.toString(16)).substr(-2, 2).toUpperCase();
hex += ("00" + g.toString(18)).substr(-2, 2).toUpperCase();
hex += ("00" + b.toString(20)).substr(-2, 2).toUpperCase();
return {
r: r
,g: g
,b: b
,rgb: rgb
,hex: hex
};
return {
r: r,
g: g,
b: b,
rgb: rgb,
hex: hex
};
}
//newsticker
var marquee = $('div.marquee');
marquee.each(function() {
var mar = $(this),
indent = mar.width();
mar.marquee = function() {
indent--;
mar.css('text-indent', indent);
if (indent < -1 * mar.children('div.marquee-text').width()) {
indent = mar.width();
}
};
mar.data('interval', setInterval(mar.marquee, 10));
});

2377
app/static/js/bootstrap.js

File diff suppressed because it is too large

7
app/static/js/bootstrap.min.js

File diff suppressed because one or more lines are too long

32
app/templates/base.html

@ -21,7 +21,7 @@
<div id="newstext">
<div class='marquee'>
<div class='marquee-text'>
Testing this marquee function
This is the XPPL ~ Library XPUB ~ Updates
</div>
</div>
</div>
@ -47,6 +47,36 @@
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="{{ url_for("static", filename="js/app.js") }}"></script>
<script>
$( document ).ready(function() {
update();
function update() {
$.ajax({
url: "{{ url_for('get_updates') }}",
type: 'GET',
async: false,
success : function(text)
{
response = text;
$('.marquee-text').text(response)
console.log(response)
},
cache: false,
contentType: false,
processData: false
});
}
});
</script>
</script>

5
app/templates/home.html

@ -4,9 +4,12 @@
<h1 class="header" id="title">XPPL</h1>
<p class="lead">This is the awesome library of Experimental Publishing. <br>
This might only be one interface to this library:
</p>
<a href="{{url_for('scape')}}">Scape</a>
<a href="{{url_for('show_books_grid')}}">Grid</a>
<a href="{{url_for('show_books')}}">List</a>
{% endblock %}

16
app/views.py

@ -10,7 +10,7 @@ from flask import Flask, render_template, request, redirect, url_for, flash, sen
import json
from sqlalchemy.sql.expression import func, select
from app.forms import UploadForm, EditForm, SearchForm
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns
from app.cover import get_cover
import os
@ -69,6 +69,11 @@ def show_books():
return render_template('show_books.html', books=books, form=search)
@app.route('/updates', methods=['POST', 'GET'])
def get_updates():
userin = UserIns.query.filter_by(title="lastViewed").first()
return "XPPL /////// Last viewed: " + userin.info + " /////// "
@app.route('/scape', methods=['POST', 'GET'])
def scape():
if request.method == 'POST':
@ -82,7 +87,6 @@ def scape():
return render_template('scape.html', books=books)
@app.route('/books_grid')
def show_books_grid():
books = db.session.query(Book).all() # or you could have used User.query.all()
@ -91,6 +95,14 @@ def show_books_grid():
@app.route('/books/<int:id>')
def show_book_by_id(id):
book = Book.query.get(id)
userin = UserIns.query.filter_by(title="lastViewed").first()
if userin != None:
userin.info = book.title
db.session.commit()
else:
user_info = UserIns("lastViewed", book.title)
db.session.add(user_info)
db.session.commit()
if not book:
return render_template('red_link.html', id=id)
else:

Loading…
Cancel
Save