1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-07 01:25:11 +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__) app.config.from_object(__name__)
db = Database(app) db = Database(app)
class User(db.Model):
username = CharField()
key = CharField()
created_date = DateTimeField(default=datetime.datetime.now)
class Bookmark(db.Model): class Bookmark(db.Model):
title = CharField()
url = CharField() url = CharField()
created_date = DateTimeField(default=datetime.datetime.now) created_date = DateTimeField(default=datetime.datetime.now)
image = CharField(default='') #image = CharField(default='')
tags = CharField()
class Meta: class Meta:
ordering = (('created_date', 'desc'),) ordering = (('created_date', 'desc'),)
def fetch_image(self): #def fetch_image(self):
url_hash = hashlib.md5(self.url).hexdigest() # url_hash = hashlib.md5(self.url).hexdigest()
filename = 'bookmark-%s.png' % url_hash # filename = 'bookmark-%s.png' % url_hash
outfile = os.path.join(MEDIA_ROOT, filename) # outfile = os.path.join(MEDIA_ROOT, filename)
params = [PHANTOM, SCRIPT, self.url, outfile] # 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('/') @app.route('/')
def index(): def index():
@@ -55,9 +65,11 @@ def add():
abort(404) abort(404)
url = request.args.get('url') url = request.args.get('url')
title = 'Temp'
tags = ''
if url: if url:
bookmark = Bookmark(url=url) bookmark = Bookmark(url=url, title=title, tags=tags)
bookmark.fetch_image() #bookmark.fetch_image()
bookmark.save() bookmark.save()
return redirect(url) return redirect(url)
abort(404) abort(404)
@@ -67,4 +79,4 @@ if __name__ == '__main__':
Bookmark.create_table(True) Bookmark.create_table(True)
# run the application # run the application
app.run() app.run(port=9999)

3
requirements.txt Normal file
View File

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