diff --git a/publish.bat b/publish.bat new file mode 100644 index 00000000..39d5c62e --- /dev/null +++ b/publish.bat @@ -0,0 +1,2 @@ +git commit -am "publish: %1" +git push && poetry build && poetry publish && hub release create "%1" -m "Wikipack %1" diff --git a/pyproject.toml b/pyproject.toml index 6da163be..61838c5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [tool.poetry] name = "wikipack" description = "A Wiki for Royalnet" - version = "0.1.0" + version = "1.0.0" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" homepage = "https://github.com/Steffo99/wikipack/" @@ -20,7 +20,7 @@ python = "^3.8" [tool.poetry.dependencies.royalnet] - version = "~5.8.16" + version = "~5.9.0" extras = [ "alchemy_easy", "constellation", diff --git a/wikipack/stars/__init__.py b/wikipack/stars/__init__.py index 4ed81310..3c471f8e 100644 --- a/wikipack/stars/__init__.py +++ b/wikipack/stars/__init__.py @@ -1,9 +1,11 @@ # Imports go here! from .api_wiki import ApiWikiStar +from .api_wiki_list import ApiWikiListStar # Enter the PageStars of your Pack here! available_page_stars = [ - ApiWikiStar + ApiWikiStar, + ApiWikiListStar, ] # Don't change this, it should automatically generate __all__ diff --git a/wikipack/stars/api_wiki_list.py b/wikipack/stars/api_wiki_list.py new file mode 100644 index 00000000..94584b9e --- /dev/null +++ b/wikipack/stars/api_wiki_list.py @@ -0,0 +1,48 @@ +from typing import * +import datetime +import royalnet.constellation.api as rca +import royalnet.utils as ru +import royalnet.backpack.tables as rbt +from ..tables import * +import sqlalchemy as s + + +class ApiWikiListStar(rca.ApiStar): + path = "/api/wiki/list/v2" + + tags = ["wiki"] + + methods = ["GET"] + + parameters = { + "get": {}, + } + + auth = { + "get": False, + } + + async def get(self, data: rca.ApiData) -> ru.JSON: + """Get the details of a specific Wiki page.""" + WikiRevisionT = self.alchemy.get(WikiRevision) + + lrs = await ru.asyncify( + data.session + .query(WikiRevisionT.page_id, s.func.max(WikiRevisionT.revision_id)) + .group_by(WikiRevisionT.page_id) + .all + ) + + pages = [] + + for page_id, revision_id in lrs: + page = await ru.asyncify( + data.session + .query(WikiRevisionT) + .get, + (page_id, revision_id) + ) + + pages.append(page) + + return [r.json_list() for r in pages] diff --git a/wikipack/version.py b/wikipack/version.py index 9ee900d3..be8b6b0b 100644 --- a/wikipack/version.py +++ b/wikipack/version.py @@ -1 +1 @@ -semantic = "0.1.0" +semantic = "1.0.0"