diff --git a/shop.py b/shop.py index 8e4bcce..12890f3 100644 --- a/shop.py +++ b/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'\1', 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') diff --git a/templates/layout.html b/templates/layout.html index 3ae098a..6f34231 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -2,7 +2,7 @@
-