Skip to content

Commit

Permalink
Merge pull request #15 from RydalWater/post-mvp-fixes-and-enhancements
Browse files Browse the repository at this point in the history
Post-v0.1.0 Fixes, Updates and Enhancements
  • Loading branch information
RydalWater authored Oct 26, 2024
2 parents 19edccc + ecadee2 commit ced45c7
Show file tree
Hide file tree
Showing 26 changed files with 262 additions and 120 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
__pycache__*
node_modules
*.log
staticfiles
staticfiles
package.json
package-lock.json
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Open Librarian is a website for tracking and sharing a love of books. It utilize
- Reading progress
- Book-related social groups

If you'd like to take a look at my backlog you can find it [on Craft](https://parks-take-vcv.craft.me/OpenLibrarianRoadmap).

## Open Source Stack
Open Librarian is built on a range of Free and Open Source Software (FOSS) projects, the most prominent of which are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
{% block content %}

<div class="container mt-2">
<p class="fw-bold">Friends & Foes</p>
<div class="chapter-header">
<p>Friends & Foes</p>
</div>
</div>

<form method="post">
Expand Down Expand Up @@ -44,7 +46,7 @@ <h2 class="accordion-header" id="friends">
</ul>
{% endfor %}
{% else %}
<p>No users currently added to your friends list.</p>
<p class="book-text text-center">No users currently added to your friends list.</p>
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -78,7 +80,7 @@ <h2 class="accordion-header" id="foes">
</ul>
{% endfor %}
{% else %}
<p>No users currently added to your muted list.</p>
<p class="book-text text-center">No users currently added to your muted list.</p>
{% endif %}
</div>
</div>
Expand Down
63 changes: 35 additions & 28 deletions openlibrarian_root/almanac/templates/almanac/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,88 +6,90 @@
{% block content %}

<div class="container mt-2">
<p class="fw-bold">Profile</p>
<div class="chapter-header">
<p>Profile</p>
</div>
</div>

<form method="post">
{% csrf_token %}
<!-- User Profile Info -->
{% if nsec %}
{% if session.nsec %}
<div style="height: 55vh; overflow-y: auto;">
<div class="input-group-sm text-start">
<label for="edit_nym" class="form-label">Account Nym</label>
<label for="edit_nym" class="form-label book-text">Account Nym</label>
{% if nym %}
<input class="form-control" type="text", name="edit_nym", value="{{ nym }}"></input>
<input class="form-control" type="text", name="edit_nym", value="{{ session.nym }}"></input>
{% else %}
<input class="form-control" type="text", name="edit_nym", placeholder="Enter your user nym"></input>
{% endif %}
</div>
<div class="accordion-flush" id="nym-info">
<div class="accordion-item">
<p class="accordion-header" id="headingOne">
<button class="accordion-button collapsed d-block text-center" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<button class="accordion-button collapsed d-block text-center book-text" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<i class="fa-solid fa-circle-info"></i> What is a Nym?
</button>
</p>
<div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#nym-info">
<div class="accordion-body">
<p class="mt-2">
Your Nym is a simple way for you would like your account to be referred to.
<p class="mt-2 book-text">
<span class="dropcap">Y</span>our Nym is a simple way for you would like your account to be referred to.
It can be changed any time and doesn't need to be unique to you. Think of it as a nickname, alias or user name.
</p>
<p>
<p class="book-text">
We <b>DO NOT</b> recommend using your real name as your Nym as it potentially creates a permanent link
etween your account and you as an individual.
between your account and you as an individual.
</p>
<p>
<p class="book-text">
If you are unsure what to put how about picking your favorite character from a book, or maybe randomly generating one.
</p>
</div>
</div>
</div>
</div>
{% if profile %}
{% if session.profile %}
<div class="input-group-sm text-start">
<label for="edit_displayname" class="form-label mt-1">Display Name</label>
{% if profile.displayname %}
<input class="form-control" type="text", name="edit_displayname", value="{{ profile.displayname }}"></input>
<label for="edit_displayname" class="form-label mt-1 book-text">Display Name</label>
{% if session.profile.displayname %}
<input class="form-control" type="text", name="edit_displayname", value="{{ session.profile.displayname }}"></input>
{% else %}
<input class="form-control" type="text", name="edit_displayname", placeholder="Enter your preferred display name"></input>
{% endif %}
<label for="edit_about" class="form-label mt-1">About</label>
{% if profile.about %}
<textarea class="form-control" type="text", name="edit_about", maxlength="200">{{ profile.about }}</textarea>
<label for="edit_about" class="form-label mt-1 book-text">About</label>
{% if session.profile.about %}
<textarea class="form-control" type="text", name="edit_about", maxlength="200">{{ session.profile.about }}</textarea>
{% else %}
<textarea class="form-control" type="text", name="edit_about", placeholder="Write a bit about yourself (max. 200 characters)" maxlength="200"></textarea>
{% endif %}
<label for="edit_picture" class="form-label mt-1">Profile Picture</label>
<label for="edit_picture" class="form-label mt-1 book-text">Profile Picture</label>
<div class="input-group input-group-sm">
{% if profile.picture %}
<input class="form-control" type="text", name="edit_picture", value="{{ profile.picture }}" aria-describedby="upload"></input>
{% if session.profile.picture %}
<input class="form-control" type="text", name="edit_picture", value="{{ session.profile.picture }}" aria-describedby="upload"></input>
{% else %}
<input class="form-control" type="text", name="edit_picture", placeholder="Enter your Picture URL" aria-describedby="upload"></input>
{% endif %}
<!-- <button class="btn btn-outline-secondary" type="button" id="upload"><i class="fa-solid fa-cloud-arrow-up"></i></button> -->
</div>
<label for="edit_nip05" class="form-label mt-1">NIP05</label>
{% if profile.nip05 %}
<input class="form-control" type="text", name="edit_nip05", value="{{ profile.nip05 }}"></input>
<label for="edit_nip05" class="form-label mt-1 book-text">NIP05</label>
{% if session.profile.nip05 %}
<input class="form-control" type="text", name="edit_nip05", value="{{ session.profile.nip05 }}"></input>
{% else %}
<input class="form-control" type="text", name="edit_nip05", placeholder="Enter your NIP05"></input>
{% endif %}
</div>
{% else %}
<div class="input-group-sm text-start">
<label for="edit_displayname" class="form-label mt-1">Display Name</label>
<label for="edit_displayname" class="form-label mt-1 book-text">Display Name</label>
<input class="form-control" type="text", name="edit_displayname", placeholder="Enter your preferred display name"></input>
<label for="edit_about" class="form-label mt-1">About</label>
<label for="edit_about" class="form-label mt-1 book-text">About</label>
<textarea class="form-control" type="text", name="edit_about", placeholder="Write a bit about yourself (max. 200 characters)" maxlength="200"></textarea>
<label for="edit_picture" class="form-label mt-1">Picture</label>
<label for="edit_picture" class="form-label mt-1 book-text">Picture</label>
<div class="input-group input-group-sm">
<input class="form-control" type="text", name="edit_picture", placeholder="Enter your Picture URL" aria-describedby="upload"></input>
<!-- <button class="btn btn-outline-secondary" type="button" id="upload"><i class="fa-solid fa-cloud-arrow-up"></i></button> -->
</div>
<label for="edit_nip05" class="form-label mt-1">NIP05</label>
<label for="edit_nip05" class="form-label mt-1 book-text">NIP05</label>
<input class="form-control" type="text", name="edit_nip05", placeholder="Enter your NIP05"></input>
</div>
{% endif %}
Expand All @@ -99,7 +101,7 @@
<!-- Save/Refresh Button -->
<div class="gap-2 mx-auto d-flex justify-content-between mt-2">
<a href="{% url 'almanac:settings' %}" class="btn btn-sm btn-secondary w-50"><i class="fa-solid fa-arrow-left"></i> Back</a>
{% if nsec %}
{% if session.nsec %}
<button id="submit" class="btn btn-sm btn-primary w-50" type="submit", name="refresh", value="Refresh"><i class="fa-solid fa-arrows-rotate"></i> Refresh</button>
<button class="btn btn-sm btn-primary w-50" type="submit", name="save", value="Save"><i class="fa-solid fa-save"></i> Save</button>
{% endif %}
Expand All @@ -109,4 +111,9 @@
</div>
</form>

<input type="hidden" id="notification" value="{{ notification }}">
<div id="toastContainer" class="position-fixed top-0 start-50 translate-middle-x p-3"></div>

<script src="{% static 'js/add-toast.js' %}"></script>

{% endblock content %}
20 changes: 11 additions & 9 deletions openlibrarian_root/almanac/templates/almanac/user_relays.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{% block content %}

<div class="container mt-2">
<p class="fw-bold">Relays</p>
<div class="chapter-header">
<p>Relays</p>
</div>
</div>

<form method="post">
Expand All @@ -12,17 +14,17 @@
<div style="height: 40vh; overflow-y: auto;">
<div class="accordion-flush mt-2" id="relay-info">
<div class="accordion-item">
<p class="accordion-header" id="headingOne">
<p class="accordion-header book-text" id="headingOne">
<button class="accordion-button collapsed d-block text-center" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<i class="fa-solid fa-circle-info"></i> What is a Relay?
</button>
</p>
<div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#relay-info">
<div class="accordion-body">
<p class="mt-2">
Relays are the backbone of the Nostr network. They are effectively databases that store your event information.
<p class="mt-2 book-text">
<span class="dropcap">R</span>elays are the backbone of the Nostr network. They are effectively databases that store your event information.
</p>
<p>
<p class="book-text">
You <b>MUST</b> have at least one relay that is read and write. You can add more if you wish but it is recommended
to only have 3-5.
</p>
Expand All @@ -35,7 +37,7 @@
</div>
{% if mod_relays %}
{% for key, value in mod_relays.items %}
<ul class="list-group text-start bg-secondary-container">
<ul class="list-group text-start bg-secondary-container mt-1">
{% if nsec %}
<li class="list-group-item container d-flex justify-content-between align-items-center">
<div class="col-2">
Expand Down Expand Up @@ -63,15 +65,15 @@
{% endfor %}
{% if messages %}
{% for message in messages %}
<p class="text text-danger">{{ message }}</p>
<p class="text text-danger book-text text-center">{{ message }}</p>
{% endfor %}
{% endif %}
{% endif %}
</div>
<div style="height: 15vh; overflow-y: auto;">
{% if nsec %}
<div class="text-start">
<label for="add_relay_url" class="form-label mt-1">Add Relay</label>
<div>
<label for="add_relay_url" class="form-label mt-1 book-text text-center fw-bold">Add Relay</label>
<div class="input-group input-group-sm">
<input class="form-control" type="text", name="add_relay_url", placeholder="Enter a relay and click add"></input>
<button class="btn btn-sm btn-outline-secondary" type="submit" name="add_relay" value="Save">Add</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
{% block content %}

<div class="container mt-2">
<p class="fw-bold">Almanac</p>
<p>Here you'll find settings and profile information. </p>
<div class="chapter-header">
<p>Almanac</p>
</div>
<p class="book-text text-center">Here you'll find settings and profile information. </p>
</div>

<div class="container">
Expand Down
39 changes: 17 additions & 22 deletions openlibrarian_root/almanac/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.shortcuts import render, redirect
from django.core.cache import cache
from django.contrib import messages
from utils.Session import async_logged_in, async_get_session_info, async_set_session_info, cache_get, cache_set, cache_key, cache_delete
from utils.Profile import edit_profile_info, edit_relay_list, fetch_profile_info
Expand Down Expand Up @@ -31,7 +30,7 @@ async def user_profile(request):
session = await async_get_session_info(request)

if request.method == 'GET':
return render(request, 'almanac/user_profile.html', session)
notification = None

# If POST then update the user profile
elif request.method == 'POST' and await async_logged_in(request) and request.POST.get('save'):
Expand All @@ -43,30 +42,19 @@ async def user_profile(request):
picture_field = request.POST.get('edit_picture', None)

# Update the profile
nym_profile = {
"nym" : nym_field,
"nip05" : nip05_field,
"displayname" : displayname_field,
"about" : about_field,
"picture" : picture_field
}
session["profile"]["nym"] = nym_field
session["profile"]["nip05"] = nip05_field
session["profile"]["displayname"] = displayname_field
session["profile"]["about"] = about_field
session["profile"]["picture"] = picture_field

if check_nsec(session['nsec']):
await edit_profile_info(nym_profile, session['relays'], session['nsec'])
await edit_profile_info(session["profile"], session['relays'], session['nsec'])

# Update Session data and re-extract
profile = {
"nym" : nym_field,
"nip05" : nip05_field,
"displayname" : displayname_field,
"about" : about_field,
"picture" : picture_field
}

await async_set_session_info(request, profile=profile, nym=nym_field)
await async_set_session_info(request, profile=session["profile"], nym=nym_field)
session = await async_get_session_info(request)

return render(request, 'almanac/user_profile.html', session)
notification = "Profile Updated"

# Perform refresh of the user profile content
if request.method == 'POST' and await async_logged_in(request) and request.POST.get('refresh'):
Expand All @@ -81,7 +69,14 @@ async def user_profile(request):

await async_set_session_info(request,npub=npub,nsec=nsec,nym=nym,relays=relays, profile=profile)
session = await async_get_session_info(request)
return render(request, 'almanac/user_profile.html', session)
notification = "Profile Refreshed"

context = {
"session": session,
"notification": notification
}

return render(request, 'almanac/user_profile.html', context=context)

# TODO: Add functionality to handle profile uploads with Nostr.Build API

Expand Down
20 changes: 11 additions & 9 deletions openlibrarian_root/archives/templates/archives/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

{% block content %}
<div class="container mt-2">
<p class="fw-bold">Current Features</p>
<div class="chapter-header">
<p>Current Features</p>
</div>
<ul class="list-group text-start">
<li class="list-group-item">User profile</li>
<li class="list-group-item">Relays</li>
Expand All @@ -13,14 +15,14 @@
<li class="list-group-item">Import Friends/Foes Lists</li>
</ul>
</div>
<div class="container mt-2"></div>
<p class="fw-bold">Privacy</p>
<p>We don't collect any personal information.</p>
<p>All your key and other data live on your browser in the cache or on relays, there is no backend server.</p>
<p>We do not track you except with cross-site request forgery protection.</p>
<p>We are not responsible for any misuse of this app or the data which you share with relays.</p>
<p>This app is open source and available under MIT License on <a href="https://github.com/RydalWater/OpenLibrarian" target="_blank">GitHub</a>.</p>
<p>Thank you for using Open Librarian!</p>
<div class="container mt-2">
<div class="chapter-header">
<p>Privacy</p>
</div>
<p class="book-text"><span class="dropcap">W</span>e don't collect any personal information. Your keys and other data live on your browser in the cache and all signatures happen locally, there is no backend server.</p>
<p class="book-text">We do not track you except with cross-site request forgery protection. Therefore, we are not responsible for any misuse of this app.</p>
<p class="book-text">Similarly, we are not responsible for any data which you share with relays please review the relay specific data policies (where available) for more details.</p>
<p class="book-text">This app is open source and available under MIT License on <a href="https://github.com/RydalWater/OpenLibrarian" target="_blank">GitHub</a>. <b>Thank you for using Open Librarian!</b></p>
</div>
{% if not npub %}
<div class="container mt-2">
Expand Down
Loading

0 comments on commit ced45c7

Please sign in to comment.