diff options
-rw-r--r-- | app/gtd/templates/gtd/reideal_code.html | 91 | ||||
-rw-r--r-- | app/gtd/urls.py | 5 | ||||
-rw-r--r-- | app/gtd/views.py | 9 |
3 files changed, 102 insertions, 3 deletions
diff --git a/app/gtd/templates/gtd/reideal_code.html b/app/gtd/templates/gtd/reideal_code.html new file mode 100644 index 0000000..165fedf --- /dev/null +++ b/app/gtd/templates/gtd/reideal_code.html @@ -0,0 +1,91 @@ +<html> + <head> +<style> +body { + padding-top: 30px; +} +.button { + color: white; + padding: 1rem; + text-decoration: none; + background-color: #2ea44f; + border: 1px solid rgba(27, 31, 35, .15); + border-radius: 6px; + box-shadow: rgba(27, 31, 35, .1) 0 1px 0; + box-sizing: border-box; + color: #fff; + cursor: pointer; + display: inline-block; + font-family: -apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; + font-size: 14px; + font-weight: 600; + line-height: 20px; + padding: 6px 16px; + position: relative; + text-align: center; + text-decoration: none; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + vertical-align: middle; + white-space: nowrap; +} +</style> + </head> + <body> + <h4 id="title"><a id="link" href=""></a></h4> + <!-- +<a class="button" href="#" onclick="CopyToClipboard('markdown');return false;">Copy Markdown</a> + +--!> +<textarea id="markdown" style="min-width: 35rem; height: 15rem;"> + +</textarea> +<script> +function capitalize(s) { + return s && s[0].toUpperCase() + s.slice(1); +} +var url = new URL(document.location); +var params = new URLSearchParams(url.search); +if(params.has("sale")){ + var sale = params.get("sale"); +} else { + var sale = "tk"; +} +if(params.has("price")){ + var price = params.get("price").substring(1); +} else { + var price = "tk"; +} +String.prototype.toProperCase = function () { + return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); +}; +const d = new URL(params.get("url")); +var site = capitalize(d.hostname.split(".com")[0].substring(4)); +var title = params.get("title").split("|")[0].trim().toProperCase(); +var str = "####"+" ["+title+" for "+price+" (tk off)]("+params.get("url")+")\n\n+++button-group\n\n[REI]("+params.get("url")+" \"REI\"){: target=\"_blank\"}\n\n+++"; +function setText() { + var el = document.getElementById('link'); + el.innerHTML = params.get("title") + " for $tk ($tk off)"; + el.href = params.get("url"); +} +function setMarkdown() { + var el = document.getElementById('markdown'); + el.value = str; +} +window.onload = function() { // Or window.addEventListener("load", function() { + //setText(); + setMarkdown(); +} +function CopyToClipboard(id) +{ +var r = document.createRange(); +r.selectNode(document.getElementById(id)); +window.getSelection().removeAllRanges(); +window.getSelection().addRange(r); +document.execCommand('copy'); +window.getSelection().removeAllRanges(); +} +</script> +</body> +</html> diff --git a/app/gtd/urls.py b/app/gtd/urls.py index fb62846..dd794fb 100644 --- a/app/gtd/urls.py +++ b/app/gtd/urls.py @@ -11,6 +11,11 @@ urlpatterns = [ name="code" ), path( + r'reideal', + views.WiredGenerateREIDealCodeView.as_view(), + name="reicode" + ), + path( r'todo', views.GTDNoteTODOView.as_view(), name="todo-list" diff --git a/app/gtd/views.py b/app/gtd/views.py index 709766e..cdbd29e 100644 --- a/app/gtd/views.py +++ b/app/gtd/views.py @@ -223,7 +223,7 @@ class WiredPostListView(ListView): template_name = 'gtd/wiredpost_table.html' def get_queryset(self): - return WiredPost.objects.all().order_by("-needs_update") + return WiredPost.objects.filter(post_type=1,author="Scott Gilbertson").order_by("-needs_update") class WiredPostUpdateOverdueView(RedirectView): @@ -296,6 +296,10 @@ class WiredGenerateDealCodeView(TemplateView): template_name = "gtd/deal_code.html" +class WiredGenerateREIDealCodeView(TemplateView): + template_name = "gtd/reideal_code.html" + + class GTDNoteDeleteView(DeleteView): # specify the model you want to use model = GTDNote @@ -349,7 +353,7 @@ class UpdateDateView(RedirectView): query_string = True def get_redirect_url(self, *args, **kwargs): - for post in WiredPost.objects.all(): + for post in WiredPost.objects.filter(post_type=1,author="Scott Gilbertson"): if post.url: content = requests.get(post.url) soup = BeautifulSoup(content.text, 'html.parser') @@ -358,4 +362,3 @@ class UpdateDateView(RedirectView): post.date_last_pub = time post.save() return super().get_redirect_url(*args, **kwargs) - |