Skip to content

Commit

Permalink
code.core>modify.fix: fix bug when working with ui when url_base is a…
Browse files Browse the repository at this point in the history
… relative url or a sub directory
  • Loading branch information
pwnfan committed Aug 7, 2023
1 parent c1ae689 commit 10823a8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
7 changes: 6 additions & 1 deletion tagmark/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,12 @@ def auto_tag_def(
help="(formatter) configuration file path",
)
@click.option(
"-u", "--url-base", type=str, help="url base for generating formatted links"
"-u",
"--url-base",
type=str,
default="./",
show_default=True,
help="url base for generating formatted links",
)
@click.option(
"-c",
Expand Down
4 changes: 2 additions & 2 deletions tagmark/tools/maketagdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
tagmark_jsonlines_data_path: Path,
tags_json_path: Path,
config_path: Path,
url_base: str,
url_base: str = "./",
condition_json_path: Path | None = None,
is_ban_condition: bool = True,
):
Expand All @@ -48,7 +48,7 @@ def __init__(
self._config_path: Path = config_path
self._condition_json_path: Path = condition_json_path
self._is_ban_condition: bool = is_ban_condition
self.url_base: str = url_base.rstrip("/")
self.url_base: str = url_base

self.converter: convert_tagmark.JsonLinesConverter
self.__load_tagmark_data()
Expand Down
8 changes: 4 additions & 4 deletions tagmark/tools/maketagdoc.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ regex = "{{((.*?):(.*?))}}"
[formatter.value.format_expression]
total = "[All TagMarks]({url_base}) `Total {filter.count_total} (Github {filter.count_github})`"
tag = "{tag_item.formatted_name}" # `tag_item` is the instance on tagmark.core.tag.TagItem
filter = "({url_base}/?tags={filter.as_url_param})" # `filter` is the instance of tagmark.core.data.TagmarkFilter
tag_filter_counts = "[{tag_item.formatted_name}]({url_base}/?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
tag_filter = "[{tag_item.formatted_name}]({url_base}/?tags={filter.as_url_param})"
filter_counts = "({url_base}/?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
filter = "({url_base}?tags={filter.as_url_param})" # `filter` is the instance of tagmark.core.data.TagmarkFilter
tag_filter_counts = "[{tag_item.formatted_name}]({url_base}?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
tag_filter = "[{tag_item.formatted_name}]({url_base}?tags={filter.as_url_param})"
filter_counts = "({url_base}?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
4 changes: 2 additions & 2 deletions tests/data/maketagdoc_result.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

* [All TagMarks](https://pwnfan.github.io/tagmark) `Total 2 (Github 2)`

* test line #1: line start, [library / package / module](https://pwnfan.github.io/tagmark/?tags=library) `Total 2 (Github 2)`. line middle, [development bookmarks with count](https://pwnfan.github.io/tagmark/?tags=dev) `Total 2 (Github 2)`, line end.
* test line #1: line start, [library / package / module](https://pwnfan.github.io/tagmark?tags=library) `Total 2 (Github 2)`. line middle, [development bookmarks with count](https://pwnfan.github.io/tagmark?tags=dev) `Total 2 (Github 2)`, line end.
* test line #2: {{xxxyyy}}
* test line #3: line start, [library / package / module](https://pwnfan.github.io/tagmark/?tags=library). line middle, [development bookmarks without count](https://pwnfan.github.io/tagmark/?tags=dev+AND+license) , only tag: `development` , line end.
* test line #3: line start, [library / package / module](https://pwnfan.github.io/tagmark?tags=library). line middle, [development bookmarks without count](https://pwnfan.github.io/tagmark?tags=dev+AND+license) , only tag: `development` , line end.
2 changes: 1 addition & 1 deletion tests/tools/test_maketagdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setup(cls, test_input_file_paths):
tagmark_jsonlines_data_path=test_input_file_paths["tagmark_jsonlines_data"],
tags_json_path=test_input_file_paths["tags_json"],
config_path=Path("tagmark/tools/maketagdoc.toml.default").absolute(),
url_base="https://pwnfan.github.io/tagmark/",
url_base="https://pwnfan.github.io/tagmark",
condition_json_path=test_input_file_paths["condition_json"],
is_ban_condition=True,
)
Expand Down

0 comments on commit 10823a8

Please sign in to comment.