1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 20:55:10 +01:00

Started making it mine; fleshing out user-based stuff

This commit is contained in:
2016-07-07 14:45:50 +02:00
parent 592b81561f
commit 6537012317
2 changed files with 27 additions and 12 deletions

View File

@@ -25,24 +25,34 @@ app = Flask(__name__)
app.config.from_object(__name__)
db = Database(app)
class User(db.Model):
username = CharField()
key = CharField()
created_date = DateTimeField(default=datetime.datetime.now)
class Bookmark(db.Model):
title = CharField()
url = CharField()
created_date = DateTimeField(default=datetime.datetime.now)
image = CharField(default='')
#image = CharField(default='')
tags = CharField()
class Meta:
ordering = (('created_date', 'desc'),)
def fetch_image(self):
url_hash = hashlib.md5(self.url).hexdigest()
filename = 'bookmark-%s.png' % url_hash
#def fetch_image(self):
# url_hash = hashlib.md5(self.url).hexdigest()
# filename = 'bookmark-%s.png' % url_hash
outfile = os.path.join(MEDIA_ROOT, filename)
params = [PHANTOM, SCRIPT, self.url, outfile]
# outfile = os.path.join(MEDIA_ROOT, filename)
# params = [PHANTOM, SCRIPT, self.url, outfile]
# exitcode = subprocess.call(params)
# if exitcode == 0:
# self.image = os.path.join(MEDIA_URL, filename)
exitcode = subprocess.call(params)
if exitcode == 0:
self.image = os.path.join(MEDIA_URL, filename)
@app.route('/')
def index():
@@ -55,9 +65,11 @@ def add():
abort(404)
url = request.args.get('url')
title = 'Temp'
tags = ''
if url:
bookmark = Bookmark(url=url)
bookmark.fetch_image()
bookmark = Bookmark(url=url, title=title, tags=tags)
#bookmark.fetch_image()
bookmark.save()
return redirect(url)
abort(404)
@@ -67,4 +79,4 @@ if __name__ == '__main__':
Bookmark.create_table(True)
# run the application
app.run()
app.run(port=9999)

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
flask
peewee
flask-peewee