Skip to content

Commit

Permalink
changed settings; moved bookmarklet into the settings section
Browse files Browse the repository at this point in the history
  • Loading branch information
synthomat committed Oct 27, 2024
1 parent 116d104 commit 96829ce
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 51 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [0.12] – UNRELEASED

## [0.11] – 2024-09-03
### Added
* User settings! Starting with control whether links should open in a new window or not.
Expand Down
15 changes: 6 additions & 9 deletions resources/templates/_main-nav.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<div>
<nav aria-label="main navigation" class="navbar" role="navigation" style="border-bottom: #eaeaea 1px solid;">
<div class="navbar-brand"><a class="navbar-item" href="/"
style="font-size: 1.4em; font-weight: bold;">myuri<span style="color: red">*</span></a><a
style="font-size: 1.4em; font-weight: bold;">myuri<span style="color: red">°</span></a><a
aria-expanded="false" aria-label="menu" class="navbar-burger" data-target="navMenu" role="button"><span
aria-hidden="true"></span><span aria-hidden="true"></span><span aria-hidden="true"></span></a></div>
<div class="navbar-menu" id="navMenu">

{% if req.session.identity %}
<div class="navbar-start"><a class="navbar-item" href="/">Home</a>
<div class="navbar-item"><a class="button is-small is-light is-link" href="/new">New</a></div>
Expand All @@ -14,13 +15,10 @@
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons"><a class="button is-small"
href="javascript:var data={url:document.location.href,title:document.title,description:document.querySelector('head>meta[name=description]')?.content,bmv:1};
window.open('{{app-addr}}/new?p=1&data='+encodeURIComponent(JSON.stringify(data)), '', 'width=600,height=350')">Bookmarklet</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable"><a class="navbar-link">{{ req.identity.username}}</a>
<div class="navbar-item has-dropdown is-hoverable"><a class="navbar-link">
{{ req.identity.username}}
{% if identity.is-admin %}<span style="color:red">*</span>{% endif %}
</a>
<div class="navbar-dropdown is-right">
<a class="navbar-item" href="/settings">Settings</a>
<hr class="navbar-divider">
Expand All @@ -29,7 +27,6 @@
<hr class="navbar-divider">
{% endif %}
<a class="navbar-item" href="/" hx-post="/auth/logout" hx-target="body">Log out</a></div>

</div>
</div>
{% else %}
Expand Down
46 changes: 22 additions & 24 deletions resources/templates/bookmarks/edit-bm.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,32 @@

<div class="container" style="margin-top: 30px;">
<h3 class="is-size-3">Edit Bookmark</h3>
<div style="padding: 10px">
<form action="/bookmarks/{{ bm.bookmarks/id }}/edit" method="post">
<input type="hidden" name="__anti-forgery-token" value="{{ req.anti-forgery-token }}">
<div class="field">
<label for="" class="label">URL</label>
<div class="control">
<input type="text" class="input" name="url" value="{{bm.bookmarks/site_url}}" required />
</div>
<form action="/bookmarks/{{ bm.bookmarks/id }}/edit" method="post">
<input type="hidden" name="__anti-forgery-token" value="{{ req.anti-forgery-token }}">
<div class="field">
<label for="" class="label">URL</label>
<div class="control">
<input type="text" class="input" name="url" value="{{bm.bookmarks/site_url}}" required/>
</div>
<div class="field">
<label for="" class="label">Title</label>
<div class="control">
<input type="text" class="input" name="title" value="{{bm.bookmarks/site_title}}" />
</div>
</div>
<div class="field">
<label for="" class="label">Title</label>
<div class="control">
<input type="text" class="input" name="title" value="{{bm.bookmarks/site_title}}"/>
</div>
<div class="field">
<label for="" class="label">Description</label>
<div class="control">
<textarea class="textarea" name="description">{{bm.bookmarks/site_description}}</textarea>
</div>
</div>
<div class="field">
<label for="" class="label">Description</label>
<div class="control">
<textarea class="textarea" name="description" rows="2">{{bm.bookmarks/site_description}}</textarea>
</div>
<div class="field">
<div class="control">
<input type="submit" class="button is-link" value="update" />
</div>
</div>
<div class="field">
<div class="control">
<input type="submit" class="button is-link" value="update"/>
</div>
</form>
</div>
</div>
</form>
</div>

{% endblock %}
26 changes: 15 additions & 11 deletions resources/templates/bookmarks/new-bm.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,38 @@

{% block page %}

{% if not p %}
<div class="container" style="margin-top: 30px;">
{% if not p %}<h3 class="is-size-3">Add Bookmark</h3>{% endif %}
<div style="padding: 10px">
<h3 class="is-size-3">New Bookmark</h3>
<div>
{% else %}
<div class="container">
<div style="padding: 14px">
{% endif %}

<form action="/new" method="post">
{% if p %}<input type="hidden" name="close" value="{{ p }}" />{% endif %}
<input type="hidden" name="__anti-forgery-token" value="{{ req.anti-forgery-token }}" />
{% if p %}<input type="hidden" name="close" value="{{ p }}"/>{% endif %}
<input type="hidden" name="__anti-forgery-token" value="{{ req.anti-forgery-token }}"/>
<div class="field">
<label for="" class="label">URL</label>
<div class="control">
<input type="text" class="input" name="url" value="{{url}}" required />
<input type="text" class="input" name="url" value="{{url}}" required/>
</div>
</div>
<div class="field">
<label for="" class="label">Title</label>
<div class="control">
<input type="text" class="input" name="title" value="{{title}}" />
<input type="text" class="input" name="title" value="{{title}}"/>
</div>
</div>
<div class="field">
<label for="" class="label">Description</label>
<div class="control">
<textarea class="textarea" name="description">{{ description }}</textarea>
<textarea class="textarea" name="description" rows="2">{{ description }}</textarea>
</div>
</div>
<div class="field">
<div class="control">
<input type="submit" class="button is-link" value="add" autofocus />
</div>
<div class="control">
<input type="submit" class="button is-link" value="add bookmark" autofocus/>
</div>
</form>
</div>
Expand Down
File renamed without changes.
23 changes: 22 additions & 1 deletion resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% for bm in bookmarks %}
<div class="bm-item">
<a href="{{ bm.url }}" title="{{ bm.url }}" {% if us.user_settings/target_blank %}target="_blank"{% endif %}>
<div>{{ bm.title }}</div>
<div>{{ bm.title }}</div>
</a>
{% if bm.checks %}<span class="tag is-danger is-light">{{ bm.checks.status_code }}</span>{% endif %}

Expand All @@ -19,6 +19,27 @@
</div>
</div>
{% endfor %}
<!--
<div class="block" style="margin-top: 3em">
<nav class="pagination" role="navigation" aria-label="pagination">
<a href="?" class="pagination-previous">Previous</a>
<a href="#" class="pagination-next">Next page</a>
<ul class="pagination-list">
<li><a href="#" class="pagination-link" aria-label="Goto page 1">1</a></li>
<li><span class="pagination-ellipsis">&hellip;</span></li>
<li><a href="#" class="pagination-link" aria-label="Goto page 45">45</a></li>
<li><a class="pagination-link is-current"
aria-label="Page 46"
aria-current="page">46</a>
</li>
<li><a href="#" class="pagination-link" aria-label="Goto page 47">47</a></li>
<li><span class="pagination-ellipsis">&hellip;</span></li>
<li><a href="#" class="pagination-link" aria-label="Goto page 86">86</a></li>
</ul>
</nav>
</div>
-->
</div>


{% endblock %}
28 changes: 24 additions & 4 deletions resources/templates/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,37 @@
{% block content %}
<form method="post">
<input type="hidden" name="__anti-forgery-token" value="{{ req.anti-forgery-token }}"/>

<div class="field">
<label class="checkbox">
<input type="checkbox" name="target_blank" value="true" {% if us.user_settings/target_blank %}checked{% endif %}/>
Open bookmarks in a new window
</label>
<label for="" class="label">Bookmarklet</label>
<div class="controll">
<a class="button"
href="javascript:var data={url:document.location.href,title:document.title,description:document.querySelector('head>meta[name=description]')?.content,bmv:1};
window.open('{{app-addr}}/new?p=1&data='+encodeURIComponent(JSON.stringify(data)), '', 'width=600,height=360')">Add Bookmark</a>
</div>
<p class="help">Drag this bookmarklet to your bookmark bar</p>
</div>

<div class="field">
<label class="label">Open bookmarks in</label>
<div class="control">
<div class="select">
<select name="target_blank">
<option value="true" {% if us.user_settings/target_blank %}selected{% endif %}>New window</option>
<option value="false" {% if not us.user_settings/target_blank %}selected{% endif %}>Same window</option>
</select>
</div>
</div>
<p class="help">Controls whether to open bookmarks in the same or a new window</p>
</div>


<div class="control">
<div class="control">
<input type="submit" class="button is-link" value="save" autofocus/>
</div>
</div>

</form>

{% endblock %}
1 change: 0 additions & 1 deletion src/myuri/web/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
[{:keys [ds request-method] :as req
{:keys [form]} :parameters}]
(let [user-id (u/user-id req)]
(prn "hella")
(case request-method
:get (tpl-resp "settings/security.html")
:post (case (-> req :params :action)
Expand Down
2 changes: 1 addition & 1 deletion src/myuri/web/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(defn not-found-handler
"docstring"
[req]
(-> (render-file "errors/error-404.html" {:req req})
(-> (render-file "errors/404-not-found.html" {:req req})
(resp/not-found)))

(defn inject-bookmark
Expand Down

0 comments on commit 96829ce

Please sign in to comment.