urlify
This commit is contained in:
7
shop.py
7
shop.py
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# all the imports
|
||||
import sqlite3, time, datetime, hashlib, os
|
||||
import sqlite3, time, datetime, hashlib, os,re
|
||||
from shutil import copyfile
|
||||
from flask import Flask, request, session, g, redirect, url_for, \
|
||||
abort, render_template, flash
|
||||
@@ -13,6 +13,7 @@ DEBUG = False
|
||||
SECRET_KEY = 'development key'
|
||||
USERNAME = 'admin'
|
||||
PASSWORD = 'default'
|
||||
URLFINDER = re.compile("((news|telnet|nttp|file|http|ftp|https)://[^ ]+)")
|
||||
|
||||
# create our little application :)
|
||||
app = Flask(__name__)
|
||||
@@ -85,6 +86,9 @@ def scan_for_new_documents(id):
|
||||
[shop, id])
|
||||
g.db.commit()
|
||||
|
||||
def urlify(s):
|
||||
return URLFINDER.sub(r'<a href="\1" target="_blank">\1</a>', s)
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
g.db = connect_db()
|
||||
@@ -126,6 +130,7 @@ def show_shop(shopid):
|
||||
if "[ ]" in row or "[x]" in row:
|
||||
icon=u"\u2714"
|
||||
extra_class=""
|
||||
row=urlify(row)
|
||||
entries.append( dict(row=i, text=row, icon=icon, extra_class=extra_class) )
|
||||
shared_to=[]
|
||||
cur = g.db.execute('select * from shares')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8/>
|
||||
<title>Shop</title>
|
||||
<title>MDShop</title>
|
||||
<script language="javascript" src="{{ url_for('static', filename='script.js') }}"></script>
|
||||
<script language="javascript" src="{{ url_for('static', filename='table.js') }}"></script>
|
||||
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<form action="{{ url_for('toggle_item') }}" method=post class=toggle-item>
|
||||
<input type=hidden name=shopid value="{{ shopid }}" >
|
||||
{% for entry in entries %}
|
||||
<input class="submit tickbox {{ entry.extra_class }}" type=submit name=item{{ entry.row }} value="{{ entry.icon }}" >{{ entry.text }}<br>
|
||||
<input class="submit tickbox {{ entry.extra_class }}" type=submit name=item{{ entry.row }} value="{{ entry.icon }}" >{{ entry.text|safe }}<br>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user