mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-07 06:05:10 +01:00
Introduce url_hash field (used for editing etc) and edit form
This commit is contained in:
13
digimarks.py
13
digimarks.py
@@ -37,6 +37,7 @@ class Bookmark(db.Model):
|
|||||||
url = CharField()
|
url = CharField()
|
||||||
created_date = DateTimeField(default=datetime.datetime.now)
|
created_date = DateTimeField(default=datetime.datetime.now)
|
||||||
#image = CharField(default='')
|
#image = CharField(default='')
|
||||||
|
url_hash = CharField()
|
||||||
tags = CharField()
|
tags = CharField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -53,15 +54,26 @@ class Bookmark(db.Model):
|
|||||||
# if exitcode == 0:
|
# if exitcode == 0:
|
||||||
# self.image = os.path.join(MEDIA_URL, filename)
|
# self.image = os.path.join(MEDIA_URL, filename)
|
||||||
|
|
||||||
|
def sethash(self):
|
||||||
|
self.url_hash = hashlib.md5(self.url).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return object_list('index.html', Bookmark.select())
|
return object_list('index.html', Bookmark.select())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<userkey>/')
|
@app.route('/<userkey>/')
|
||||||
def bookmarks(userkey):
|
def bookmarks(userkey):
|
||||||
return object_list('bookmarks.html', Bookmark.select())
|
return object_list('bookmarks.html', Bookmark.select())
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/<userkey>/edit/<urlhash>')
|
||||||
|
def editbookmark(urlhash):
|
||||||
|
# bookmark = getbyurlhash()
|
||||||
|
return render_template('edit.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<userkey>/add/')
|
@app.route('/<userkey>/add/')
|
||||||
def add(userkey):
|
def add(userkey):
|
||||||
password = request.args.get('password')
|
password = request.args.get('password')
|
||||||
@@ -73,6 +85,7 @@ def add(userkey):
|
|||||||
tags = ''
|
tags = ''
|
||||||
if url:
|
if url:
|
||||||
bookmark = Bookmark(url=url, title=title, tags=tags)
|
bookmark = Bookmark(url=url, title=title, tags=tags)
|
||||||
|
bookmark.sethash()
|
||||||
#bookmark.fetch_image()
|
#bookmark.fetch_image()
|
||||||
bookmark.save()
|
bookmark.save()
|
||||||
return redirect(url)
|
return redirect(url)
|
||||||
|
|||||||
11
templates/edit.html
Normal file
11
templates/edit.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
<h1>Edit/add bookmark</h1>
|
||||||
|
|
||||||
|
<form action="{{ SERVERURI }}/{{ FORMACTION }}">
|
||||||
|
|
||||||
|
<label>Title</label> <input type="text" name="title" value="{{ title }}" />
|
||||||
|
<label>URL</label> <input type="text" name="url" value="{{ url }}" />
|
||||||
|
<label>Tags</label> <input type="text" name="tags" value="{{ tags }}" />
|
||||||
|
|
||||||
|
<input type="submit" value="Save" />
|
||||||
|
</form>
|
||||||
Reference in New Issue
Block a user