mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Implemented stripping of query parameters from url
This commit is contained in:
12
digimarks.py
12
digimarks.py
@@ -7,7 +7,7 @@ import requests
|
|||||||
import shutil
|
import shutil
|
||||||
import bs4
|
import bs4
|
||||||
from more_itertools import unique_everseen
|
from more_itertools import unique_everseen
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse, urlunparse
|
||||||
|
|
||||||
from utilkit import datetimeutil
|
from utilkit import datetimeutil
|
||||||
|
|
||||||
@@ -156,6 +156,11 @@ class Bookmark(db.Model):
|
|||||||
tags_clean = clean_tags(tags_split)
|
tags_clean = clean_tags(tags_split)
|
||||||
self.tags = ','.join(tags_clean)
|
self.tags = ','.join(tags_clean)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def strip_url_params(cls, url):
|
||||||
|
parsed = urlparse(url)
|
||||||
|
return urlunparse((parsed.scheme, parsed.netloc, parsed.path, parsed.params, '', parsed.fragment))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tags_list(self):
|
def tags_list(self):
|
||||||
""" Get the tags as a list, iterable in template """
|
""" Get the tags as a list, iterable in template """
|
||||||
@@ -283,6 +288,9 @@ def updatebookmark(userkey, request, urlhash = None):
|
|||||||
starred = False
|
starred = False
|
||||||
if request.form.get('starred'):
|
if request.form.get('starred'):
|
||||||
starred = True
|
starred = True
|
||||||
|
strip_params = False
|
||||||
|
if request.form.get('strip'):
|
||||||
|
strip_params = True
|
||||||
|
|
||||||
if url and not urlhash:
|
if url and not urlhash:
|
||||||
# New bookmark
|
# New bookmark
|
||||||
@@ -300,6 +308,8 @@ def updatebookmark(userkey, request, urlhash = None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
bookmark.title = title
|
bookmark.title = title
|
||||||
|
if strip_params:
|
||||||
|
url = Bookmark.strip_url_params(url)
|
||||||
bookmark.url = url
|
bookmark.url = url
|
||||||
bookmark.starred = starred
|
bookmark.starred = starred
|
||||||
bookmark.set_tags(tags)
|
bookmark.set_tags(tags)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input type="checkbox" name="strip" id="strip" />
|
<input type="checkbox" name="strip" id="strip" />
|
||||||
<label for="strip">Strip parameters from url</label>
|
<label for="strip">Strip parameters from url (like <em>?utm_source=social</em> - can break the link!)</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if bookmark.url_hash %}
|
{% if bookmark.url_hash %}
|
||||||
|
|||||||
Reference in New Issue
Block a user