Bubble [main]

Added Display settings page; option for shorter previews in feeds

=> f06b6603318911c0284f48aea75894e9674acf33

diff --git a/50_bubble.py b/50_bubble.py
index ba15474..ccd09c1 100644
--- a/50_bubble.py
+++ b/50_bubble.py
@@ -108,6 +108,7 @@ Bubble is open source:
             self.c_user = None   # User associated with the context subspace, if any
             self.token = None
             self.notif_count = None
+            self.is_short_preview = False
 
         def set_user(self, user):
             self.user = user
@@ -115,6 +116,7 @@ Bubble is open source:
                 if user.flags & User.ASCII_ICONS_FLAG:
                     self.CHECKS = [ '[_]', '[x]' ]
                     # TODO: Add more of these.
+                self.is_short_preview = (user.flags & User.SHORT_PREVIEW_FLAG) != 0
 
         def is_likes_enabled(self):
             enabled = self.bubble.likes_enabled
@@ -217,9 +219,12 @@ Bubble is open source:
             author = '๐ŸŒ’ ' + sub if sub else (post.poster_avatar + ' ' + post.poster_name)
             author_link = sub if sub else '/u/' + post.poster_name
 
+            SHORT_PREVIEW_LEN = 160
+
             if is_issue_tracker:
                 src = f'=> {post.page_url()} ๐Ÿž [#{post.issueid if post.issueid else 0}] {post.title}{tag}\n'
-                src += shorten_text(post.summary, 200) + '\n'
+                src += shorten_text(post.summary,
+                                    200 if not self.is_short_preview else SHORT_PREVIEW_LEN) + '\n'
                 parts = []
                 parts.append(post.poster_name)
                 if cmt: parts.append(cmt)
@@ -228,7 +233,8 @@ Bubble is open source:
                 src += f'{post.poster_avatar} {" ยท ".join(parts)}{bell}\n'
             else:
                 src = f'=> {author_link} {author}\n'
-                src += post.summary
+                src += post.summary if not self.is_short_preview \
+                    else shorten_text(post.summary, SHORT_PREVIEW_LEN) + '\n'
                 parts = []
                 if sub: parts.append(post.poster_name)
                 if cmt: parts.append(cmt)
diff --git a/model.py b/model.py
index fad643e..5332999 100644
--- a/model.py
+++ b/model.py
@@ -188,6 +188,7 @@ class User:
     HIDE_LIKES_FLAG         = 0x0004
     HIDE_REACTIONS_FLAG     = 0x0008
     HIDE_THANKS_FLAG        = 0x0010
+    SHORT_PREVIEW_FLAG      = 0x0020
 
     def __init__(self, id, name, info, url, avatar, role, flags, notif, email, email_inter, \
                  email_range, password, ts_password, ts_created, ts_active, sort_post, sort_cmt):
diff --git a/settings.py b/settings.py
index 53ce525..70d197b 100644
--- a/settings.py
+++ b/settings.py
@@ -234,7 +234,11 @@ def make_settings_page(session):
 
     elif req.path == session.path + 'settings/ascii':
         db.update_user(session.user, flags=(session.user.flags ^ User.ASCII_ICONS_FLAG))
-        return 30, '/settings'
+        return 30, './display'
+
+    elif req.path == session.path + 'settings/short-preview':
+        db.update_user(session.user, flags=(session.user.flags ^ User.SHORT_PREVIEW_FLAG))
+        return 30, './display'
 
     elif req.path == session.path + 'settings/notif':
         notif = session.user.notif
@@ -489,20 +493,31 @@ def make_settings_page(session):
                 page += '\n'
         return page
 
+    elif req.path == session.path + 'settings/display':
+        page += f'# {session.user.name}: Settings\n'
+        page += '=> /settings โš™๏ธ Go back\n\n'
+
+        ICON_MODE = [ 'Unicode/Emoji' , 'ASCII' ]
+
+        page += '## Display\n\n'
+        page += f'=> /settings/short-preview {session.CHECKS[nonzero(session.user.flags & User.SHORT_PREVIEW_FLAG)]} Short post previews\n'
+        page += f'=> /settings/ascii Display icons as: {ICON_MODE[nonzero(session.user.flags & User.ASCII_ICONS_FLAG)]}\n'
+        return page
+
     elif req.path == session.path + 'settings':
         page = f'# {session.user.name}: Settings\n'
-        page += f'\n=> /u/{session.user.name} {session.user.avatar} Back to u/{session.user.name}\n\n'
+        page += f'\n=> /dashboard Back to Dashboard\n'
+        page += f'=> / Back to front page\n\n'
 
         SORT_POST = { 'r': '๐Ÿ•‘ Most recent', 'h': '๐Ÿ”ฅ Hotness' }
         SORT_COMMENT = { 'o': 'โฌ‡ Oldest first', 'n': 'โฌ† Newest first' }
         HOME_FEED = [ 'All Posts', 'Followed' ]
-        ICON_MODE = [ 'Unicode/Emoji' , 'ASCII' ]
         user_space = db.get_subspace(owner=session.user.id)
 
         page += f'=> /settings/homefeed Home feed: {HOME_FEED[nonzero(session.user.flags & User.HOME_FOLLOWED_FEED_FLAG)]}\n'
         page += f'=> /settings/sort-feed Sort posts: {SORT_POST[session.user.sort_post]}\n'
         page += f'=> /settings/sort-cmt Sort comments: {SORT_COMMENT[session.user.sort_cmt]}\n'
-        page += f'=> /settings/ascii Display icons as: {ICON_MODE[nonzero(session.user.flags & User.ASCII_ICONS_FLAG)]}\n'
+
 
         page += f'\n=> /settings/omit-all {session.CHECKS[nonzero(user_space.flags & Subspace.OMIT_FROM_ALL_FLAG)]} ' + \
                 f'Omit u/{session.user.name} from All Posts\n'
@@ -511,6 +526,7 @@ def make_settings_page(session):
         page += 'Individual posts can be included or excluded from the Gemini feed using the composer.\n'
 
         page += '\n=> /settings/profile โš™๏ธ Profile\n'
+        page += '=> /settings/display โš™๏ธ Display\n'
         page += '=> /settings/notif โš™๏ธ Notifications\n'
         page += '=> /settings/feedback โš™๏ธ Feedback\n'
         page += '=> /settings/follow โš™๏ธ Followed and muted\n'
@@ -527,9 +543,6 @@ def make_settings_page(session):
         page += f'\n=> /settings/delete-account/{session.get_token()} โš ๏ธ Delete user {session.user.name}\n'
         page += 'All of your posts and comments will be deleted.\n'
 
-        page += '\n=> /s/ ๐ŸŒ’ Subspaces\n'
-        page += f'=> / {session.bubble.site_icon} Back to front page\n'
-
         page += f'\n๐Ÿ’ฌ Bubble v{session.bubble.version} by @jk@skyjake.fi\n'
         return page
 
Proxy Information
Original URL
gemini://git.skyjake.fi/bubble/main/cdiff/f06b6603318911c0284f48aea75894e9674acf33
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
29.818372 milliseconds
Gemini-to-HTML Time
0.321547 milliseconds

This content has been proxied by September (ba2dc).