Skip to content

Refactor: Shinylive URL encode/decode #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f829802
Refactor `url_{encode,decode}` to return a ShinyliveIoApp object
gadenbuie Jan 22, 2024
babd4fe
Add +/- methods for ShinyliveIoAppLocal
gadenbuie Jan 22, 2024
88a086c
docs: document all the things
gadenbuie Jan 22, 2024
4ae8018
feat(url_decode): Track mode/header in object
gadenbuie Jan 22, 2024
279a934
tests: Add some very basic tests
gadenbuie Jan 22, 2024
d7d17fa
docs: update news
gadenbuie Jan 22, 2024
d992c1d
fix: Missed setting language
gadenbuie Jan 22, 2024
8481904
fix: chunk engine is `shinylive-python` not `shinylive-py`
gadenbuie Jan 22, 2024
789e395
fix: Use snakecase for `viewer_height`
gadenbuie Jan 22, 2024
4614ffb
several improvements
gadenbuie Jan 23, 2024
be82671
feat: Add `add_dir()` method
gadenbuie Jan 23, 2024
bf0c661
chore: ShinyLive -> shinylive
gadenbuie Jan 23, 2024
885f84e
remove some unnecessary pythonic fanciness
gadenbuie Jan 23, 2024
b299175
Make mode, header, host public and document
gadenbuie Jan 23, 2024
05d9bcc
Add alternate constructors
gadenbuie Jan 23, 2024
d7af495
Rename class ShinyliveApp
gadenbuie Jan 23, 2024
7aa7f94
update `url_encode()` to return a string
gadenbuie Jan 23, 2024
57614ca
flip order of logical section, to prioritize True
gadenbuie Jan 23, 2024
2392841
export ShinyliveApp
gadenbuie Jan 23, 2024
8762f7a
simplify setting language attribute
gadenbuie Jan 23, 2024
d323be6
update CLI to use new ShinyliveApp constructors
gadenbuie Jan 23, 2024
1420ac0
tests: fix tests
gadenbuie Jan 23, 2024
23d15f1
fix setting header in constructor
gadenbuie Jan 23, 2024
72e9596
Add `.remove_file()` method and call in `__sub__`
gadenbuie Jan 24, 2024
9305869
Allow method chaining in ShinyliveApp methods
gadenbuie Jan 24, 2024
87fc46e
rename methods `.url()` -> `.to_url()`
gadenbuie Jan 24, 2024
6907ec2
docs: update changelog
gadenbuie Jan 24, 2024
dbc60bc
docs: shinylive -> Shinylive
gadenbuie Jan 24, 2024
95ab265
remove trailing slashes from host
gadenbuie Jan 24, 2024
21a51fe
Update reference to ShinyliveIoApp
gadenbuie Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename class ShinyliveApp
  • Loading branch information
gadenbuie committed Jan 23, 2024
commit d7af4956224677ee0b9c81b8890c425f3793524e
22 changes: 11 additions & 11 deletions shinylive/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FileContentJson(TypedDict):
"""


class ShinyliveIoApp:
class ShinyliveApp:
"""
Create an instance of a Shiny App for use with shinylive.io.

Expand Down Expand Up @@ -101,7 +101,7 @@ def from_local(
files: Optional[str | Path | Sequence[str | Path]] = None,
language: Optional[Literal["py", "r"]] = None,
**kwargs: Any,
) -> ShinyliveIoApp:
) -> ShinyliveApp:
"""
Create an instance of a Shiny App from local files for use with shinylive.io.

Expand Down Expand Up @@ -148,7 +148,7 @@ def from_text(
language: Optional[Literal["py", "r"]] = None,
root_dir: Optional[str | Path] = None,
**kwargs: Any,
) -> ShinyliveIoApp:
) -> ShinyliveApp:
"""
Create an instance of a Shiny App from a string containing the `app.py` or `app.R`
file contents for use with shinylive.io.
Expand Down Expand Up @@ -186,7 +186,7 @@ def from_text(
return self

@classmethod
def from_url(cls, url: str) -> ShinyliveIoApp:
def from_url(cls, url: str) -> ShinyliveApp:
"""
Create an instance of a Shiny App from a shinylive.io URL.

Expand Down Expand Up @@ -500,16 +500,16 @@ def add_file(

self._bundle.append(file_new)

def __add__(self, other: str | Path) -> ShinyliveIoApp:
def __add__(self, other: str | Path) -> ShinyliveApp:
other = Path(other)
new: ShinyliveIoApp = copy.deepcopy(self)
new: ShinyliveApp = copy.deepcopy(self)
if other.is_dir():
new.add_dir(other)
else:
new.add_file(other)
return new

def __sub__(self, other: str | Path) -> ShinyliveIoApp:
def __sub__(self, other: str | Path) -> ShinyliveApp:
file_names = [file["name"] for file in self._bundle]
index = None

Expand All @@ -527,7 +527,7 @@ def __sub__(self, other: str | Path) -> ShinyliveIoApp:
if index is None:
raise ValueError(f"File '{other}' not found in app bundle.")

new: ShinyliveIoApp = copy.deepcopy(self)
new: ShinyliveApp = copy.deepcopy(self)
new._bundle.pop(index)
return new

Expand All @@ -538,7 +538,7 @@ def url_encode(
language: Optional[Literal["py", "r"]] = None,
mode: Literal["editor", "app"] = "editor",
header: bool = True,
) -> ShinyliveIoApp:
) -> ShinyliveApp:
"""
Generate a URL for a [shinylive application](https://shinylive.io).

Expand Down Expand Up @@ -581,7 +581,7 @@ def url_encode(
return sl_app


def url_decode(url: str) -> ShinyliveIoApp:
def url_decode(url: str) -> ShinyliveApp:
"""
Decode a Shinylive URL into a ShinyliveIoApp object.

Expand All @@ -594,7 +594,7 @@ def url_decode(url: str) -> ShinyliveIoApp:
-------
A ShinyliveIoApp object.
"""
return ShinyliveIoApp.from_url(url)
return ShinyliveApp.from_url(url)


def bundle_from_url(url: str) -> list[FileContentJson]:
Expand Down