From c50c620c27c379abe78ef3ea4c60df2cedb68f48 Mon Sep 17 00:00:00 2001 From: chimchooree Date: Tue, 20 Feb 2024 17:04:13 -0600 Subject: [PATCH] tags weren't working for stories, but I think I fixed it --- src/diary/entries/230227 | 2 +- src/index.py | 80 +++++++++++++++++++-------------------- src/views/diary-boxes.tpl | 6 +-- src/views/diary.tpl | 40 ++++++++++---------- src/views/entry.tpl | 6 +-- src/views/me.tpl | 18 ++++++++- src/views/story.tpl | 4 -- 7 files changed, 82 insertions(+), 74 deletions(-) delete mode 100644 src/views/story.tpl diff --git a/src/diary/entries/230227 b/src/diary/entries/230227 index 2441f24..dc2128d 100644 --- a/src/diary/entries/230227 +++ b/src/diary/entries/230227 @@ -1,6 +1,6 @@

Godot 3 Tutorial - Chat Room Using WebSocket

-#godot #webdev
+#godot #programming #webdev

Follow along to make your first mini WebSocket application in GDScript (with a little JSON). The client and the server will be two separate projects. I build upon the NetworkedMultiplayerENet chat room tutorial(archive link) by Miziziziz and the HTML5 and WebSocket tutorial in the Godot documentation.

diff --git a/src/index.py b/src/index.py index 73e9f66..d5a4b78 100644 --- a/src/index.py +++ b/src/index.py @@ -174,7 +174,6 @@ def list_snippets(articles, loc): a.append(find_social_title(text)) a.append(find_tags(text)) result.append(a) - print(result) return result # List latest 5 articles as headline links @@ -321,15 +320,21 @@ def list_rec(page, loc): def prepare_diary_entry(page, loc): result = [] - with open(loc + page) as f: - text = [] - text = article2list(page, loc) - result.append(find_title(text)) - result.append(retrieve_diary_entry_content(page, loc)) - result.append(find_timestamp(page)) - result.append(find_url(loc + page)) - result.append(find_social_title(text)) - result.append(find_tags(text)) + try: + with open(loc + page) as f: + text = [] + text = article2list(page, loc) + result.append(find_title(text)) + result.append(retrieve_diary_entry_content(page, loc)) + result.append(find_timestamp(page)) + result.append(find_url(loc + page)) + result.append(find_social_title(text)) + result.append(find_tags(text)) + except FileNotFoundError as e: + print("HEY - Error: " + str(e)) + print("HEY - loc: " + loc) + print("HEY - page: " + page) + print("PASS - " + loc + page) return result # Return article as list of lines of text @@ -501,9 +506,7 @@ def games(): @route('/japanese') def japanese(): """japanese""" - #info = {'css': 'cornucopia', 'title': 'studying Japanese', 'year': find_year()} - redirect('/https://blessfrey.me/diary/entries/240220') - #return template('cornucopia.tpl', info) + redirect('diary/entries/240220') # Diary Page @route('/') @@ -520,7 +523,7 @@ def diary(page): """diary""" loc = 'diary/entries/' assert isinstance(page, int) - info = {'css': 'diary', 'title': 'chimchooree\'s diary', 'year': find_year(), 'snippets': list_snippets(gather_and_sort(loc), loc), 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'total': len(curate_files(gather_files(loc))), 'limit': 8, 'cluster': 3, 'page': page} + info = {'css': 'diary', 'title': 'chimchooree\'s diary', 'year': find_year(), 'snippets': list_snippets(gather_and_sort(loc), loc), 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'total': len(curate_files(gather_files(loc))), 'limit': 8, 'cluster': 3, 'page': page, 'category': "diary"} return template('diary.tpl', info) # Entry Page - Feature Template - for articles @@ -532,7 +535,7 @@ def entry(page_t): page = str(page_t) loc = 'diary/entries/' entry = prepare_diary_entry(page, loc) - info = {'css': 'entry', 'title': entry[0] + ' (blessfrey developer diary)', 'year': find_year(), 'entry': entry, 'recommends': list_rec(page, loc), 'articles': "Articles", 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'page': page} + info = {'css': 'entry', 'title': entry[0] + ' (blessfrey developer diary)', 'year': find_year(), 'entry': entry, 'recommends': list_rec(page, loc), 'articles': "Articles", 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'page': page, 'category': "diary"} abs_app_dir_path = os.path.dirname(os.path.realpath(__file__)) abs_views_path = os.path.join(abs_app_dir_path, 'views') TEMPLATE_PATH.insert(0, abs_views_path ) @@ -606,26 +609,6 @@ def style(): info = {'css': 'doc', 'title': 'blessfrey style guide', 'year': find_year()} return template('style-guide.tpl', info) -# Location Page -@route('/location/') # if no location given -def loc3(): - return setting() -@route('/loc/') # if no location given -def loc2(): - return setting() -@route('/loc/') -def loc(page): - """location page""" - loc = 'loc/' - info = {'css': 'doc', 'title': 'blessfrey GDD - setting - ' + page, 'year': find_year(), 'topic': page.lower(), 'writeup': prepare_gdd_page(page, loc)} - return template('page-setting.tpl', info) -# loc = 'location/' -# info = {'css': 'char', 'title': 'blessfrey - location | about ' + location_name, 'year': find_year(), 'name': location_name, 'profile': prepare_profile(loc, location_name), 'gallery': find_gallery(location_name)} -# abs_app_dir_path = os.path.dirname(os.path.realpath(__file__)) -# abs_views_path = os.path.join(abs_app_dir_path, 'views') -# TEMPLATE_PATH.insert(0, abs_views_path ) -# return template(os.path.join(abs_views_path,'char.tpl'), info) - # Me Page @route('/about-me') def me(): @@ -709,16 +692,30 @@ def setting(): @route('/story') def story2(): return story("home") -@route('/story/') +@route('/story/') def story(story): """story""" loc = 'story/' entry = prepare_diary_entry(story, loc) - info = {'css': 'entry', 'title': entry[0], 'year': find_year(), 'entry': entry, 'recommends': list_rec(story, loc), 'articles': "Articles", 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'page': story} + print("HEY ... ") + print(entry) + info = {'css': 'entry', 'title': entry[0], 'year': find_year(), 'entry': entry, 'recommends': list_rec(story, loc), 'articles': "Articles", 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'page': story, 'category': "story"} abs_app_dir_path = os.path.dirname(os.path.realpath(__file__)) abs_views_path = os.path.join(abs_app_dir_path, 'views') TEMPLATE_PATH.insert(0, abs_views_path ) return template(os.path.join(abs_views_path,'entry.tpl'), info) +# Search Story by Tag +@route('/story/tag/') # Start on first Story tag page if no page given +def story_tag2(tagin): + return story_tag(tagin, 0, 'story/') +@route('/story/tag//') # Tag Page - Story Tag Template - list all articles for tag +def story_tag(tagin, page, loc): + """tag page""" + print("PASS - TAG - " + tagin) + assert isinstance(tagin, str) + assert isinstance(page, int) + info = {'css': 'diary', 'title': 'blessfrey developer diary', 'year': find_year(), 'snippets': list_snippets(pull_tag(gather_and_sort(loc), tagin, loc), loc), 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'total': len(curate_files(gather_files(loc))), 'limit': 8, 'cluster': 3, 'page': page, 'category': "story"} + return template('diary.tpl', info) # Blessfrey Wiki Page @route('/study') @@ -728,14 +725,15 @@ def study(): # Search Diary by Tag @route('/diary/tag/') # Start on first Diary tag page if no page given -def tag2(tagin): - return tag(tagin, 0, 'diary/entries/') +def diary_tag2(tagin): + return diary_tag(tagin, 0, 'diary/entries/') @route('/diary/tag//') # Tag Page - Diary Tag Template - list all articles for tag -def tag(tagin, page, loc): +def diary_tag(tagin, page, loc): """tag page""" + print("PASS - TAG - " + tagin) assert isinstance(tagin, str) assert isinstance(page, int) - info = {'css': 'diary', 'title': 'blessfrey developer diary', 'year': find_year(), 'snippets': list_snippets(pull_tag(gather_and_sort(loc), tagin, loc), loc), 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'total': len(curate_files(gather_files(loc))), 'limit': 8, 'cluster': 3, 'page': page} + info = {'css': 'diary', 'title': 'blessfrey developer diary', 'year': find_year(), 'snippets': list_snippets(pull_tag(gather_and_sort(loc), tagin, loc), loc), 'latest': list_headlines(gather_and_sort(loc)[0:5], loc), 'tags': fill_word_cloud(curate_files(gather_files(loc)), loc), 'total': len(curate_files(gather_files(loc))), 'limit': 8, 'cluster': 3, 'page': page, 'category': "diary"} return template('diary.tpl', info) ## Main ## diff --git a/src/views/diary-boxes.tpl b/src/views/diary-boxes.tpl index fc1e2d2..8deb452 100644 --- a/src/views/diary-boxes.tpl +++ b/src/views/diary-boxes.tpl @@ -3,7 +3,7 @@