Skip to content
This repository was archived by the owner on Jul 31, 2026. It is now read-only.

Commit 2bd2d6f

Browse files
authored
Merge pull request #795 from claremacrae/issue-791-sort-uncategorized-plugins
Fix #791: enable sorting of uncategorized plugins
2 parents 7d465e8 + e5c58d6 commit 2bd2d6f

3 files changed

Lines changed: 69 additions & 2 deletions

File tree

.github/scripts/plugins.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
class Plugin:
1717

1818
def __init__(self, data: PluginStorage):
19-
self.__data = data
19+
# Make a copy to avoid modifying the original input data
20+
self.__data = data.copy()
21+
22+
self.sanitize_description()
2023

2124
def repo(self) -> str:
2225
return str(self.__data.get("repo"))
@@ -77,6 +80,8 @@ def collect_data_for_plugin_and_manifest(self, manifest: PluginManifest, file_gr
7780

7881
self.__data.update(mobile=mobile, user=user, **manifest)
7982
update_author_name_for_manual_exceptions(self.__data)
83+
84+
self.sanitize_description()
8085

8186
return plugin_is_valid
8287

@@ -93,3 +98,9 @@ def validate_plugin_ids(self, manifest: PluginManifest, repo: str, file_groups:
9398
add_file_group(file_groups, "error", f"{releases_id}/{manifest_id}")
9499
ids_match = False
95100
return ids_match
101+
102+
def sanitize_description(self) -> None:
103+
# Sanitize the description in place.
104+
# See https://github.com/obsidian-community/obsidian-hub/issues/791
105+
if 'description' in self.__data:
106+
self.__data['description'] = self.__data['description'].replace('\n', ' ')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"author": "chenfeicqq",
3+
"authorUrl": "https://github.com/chenfeicqq",
4+
"description": "Attachment folder name binding note name, automatically rename, automatically delete, show/hide. \u9644\u4ef6\u6587\u4ef6\u5939\u540d\u79f0\u7ed1\u5b9a\u7b14\u8bb0\u540d\u3001\u81ea\u52a8\u91cd\u547d\u540d\u3001\u81ea\u52a8\u5220\u9664\u3001\u663e\u793a/\u9690\u85cf\u3002",
5+
"id": "attachment-manager",
6+
"isDesktopOnly": true,
7+
"minAppVersion": "0.12.17",
8+
"mobile": "[[Desktop-only plugins|No]]",
9+
"name": "Attachment Manager",
10+
"repo": "chenfeicqq/obsidian-attachment-manager",
11+
"user": "chenfeicqq",
12+
"version": "1.2.2"
13+
}

.github/scripts/tests/test_plugins.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
import plugins
44

55
from helpers_for_testing import verify_in_json_format_to_markdown
6+
from plugins import Plugin
7+
from tests.helpers_for_testing import verify_in_json_format_to_markdown
68
from utils import FileGroups
79

810

911
def verify_plugin(manifest_as_json: str, plugin_as_json: str) -> None:
12+
plugin = process_plugin(manifest_as_json, plugin_as_json)
13+
verify_in_json_format_to_markdown(plugin.data())
14+
15+
16+
def process_plugin(manifest_as_json: str, plugin_as_json: str) -> Plugin:
1017
plugin = plugins.Plugin(json.loads(plugin_as_json))
1118
manifest = json.loads(manifest_as_json)
1219
file_groups: FileGroups = dict()
1320
result = plugin.collect_data_for_plugin_and_manifest(manifest, file_groups)
14-
verify_in_json_format_to_markdown(plugin.data())
21+
return plugin
1522

1623

1724
def test_author_augmented_for_ryanjamurphy() -> None:
@@ -65,3 +72,39 @@ def test_author_missing_from_manifest() -> None:
6572
}
6673
'''
6774
verify_plugin(manifest_as_json, plugin_as_json)
75+
76+
77+
def test_description_contains_newline() -> None:
78+
# See https://github.com/obsidian-community/obsidian-hub/issues/791
79+
# This plugin's manifest.json has a newline character in the description.
80+
# This test verifies that this situation is handled correctly.
81+
plugin_as_json = '''
82+
{
83+
"id": "attachment-manager",
84+
"name": "Attachment Manager",
85+
"author": "chenfeicqq",
86+
"description": "Attachment Manager: Attachment folder name binding note name, automatically rename, automatically delete, show/hide.\\n附件管理器:附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。",
87+
"repo": "chenfeicqq/obsidian-attachment-manager"
88+
}
89+
'''
90+
plugin_from_obsidian_releases = plugins.Plugin(json.loads(plugin_as_json))
91+
assert plugin_from_obsidian_releases.data()['description'] == "Attachment Manager: Attachment folder name binding note name, automatically rename, automatically delete, show/hide. 附件管理器:附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。"
92+
93+
manifest_as_json = '''
94+
{
95+
"id": "attachment-manager",
96+
"name": "Attachment Manager",
97+
"version": "1.2.2",
98+
"minAppVersion": "0.12.17",
99+
"description": "Attachment folder name binding note name, automatically rename, automatically delete, show/hide.\\n附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。",
100+
"author": "chenfeicqq",
101+
"authorUrl": "https://github.com/chenfeicqq",
102+
"isDesktopOnly": true
103+
}
104+
'''
105+
106+
plugin_from_obsidian_releases_and_manifest = process_plugin(manifest_as_json, plugin_as_json)
107+
assert plugin_from_obsidian_releases_and_manifest.data()['description'] == "Attachment folder name binding note name, automatically rename, automatically delete, show/hide. 附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。"
108+
109+
verify_plugin(manifest_as_json, plugin_as_json)
110+

0 commit comments

Comments
 (0)