From ad67d30f207ee5d23d60c9170e2adca44016b971 Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Mon, 14 Jun 2021 13:44:19 -0700 Subject: [PATCH 1/5] gh login --- examples/github_example.py | 16 +++ examples/index.html | 10 ++ splashgen/integrations.py | 18 +++ .../templates/github_log_template.html.jinja | 136 ++++++++++++++++++ splashgen/templates/splash_site.html.jinja | 108 ++++++++++++++ 5 files changed, 288 insertions(+) create mode 100644 examples/github_example.py create mode 100644 examples/index.html create mode 100644 splashgen/templates/github_log_template.html.jinja diff --git a/examples/github_example.py b/examples/github_example.py new file mode 100644 index 0000000..b754157 --- /dev/null +++ b/examples/github_example.py @@ -0,0 +1,16 @@ +from splashgen import launch +from splashgen.components import SplashSite +from splashgen.integrations import GithubSignin + +site = SplashSite(title="Splashgen - Splash Pages Built In Python", + theme="dark") +site.headline = "Build your splash page in python effortlessly" +site.subtext = """ +In less than 20 lines of python, create clean and beautiful splash pages with +Splashgen. Don't waste time with no-code tools when you already know how to +code. +""" +site.call_to_action = GithubSignin( + "https://github.com/true3dco/splashgen", "View on GitHub") + +launch(site) diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 0000000..2868b33 --- /dev/null +++ b/examples/index.html @@ -0,0 +1,10 @@ + + + Test Page for the Nginx HTTP Server on Amazon Linux + + + + +

FILES HOSTED ON S3 LEGOOO

+ + diff --git a/splashgen/integrations.py b/splashgen/integrations.py index 62d1d5c..9cad0ec 100644 --- a/splashgen/integrations.py +++ b/splashgen/integrations.py @@ -31,3 +31,21 @@ def _parse_signup_url(self, url: str) -> Tuple[ParseResult, dict]: ps = ps._replace(path=f"{ps.path}/post") qs = query_string.parse(ps.query) return ps, qs + +class GithubSignin(Component): + + def __init__(self, link: str, text: str) -> None: + self.link = link + self.text = text + + def render(self) -> str: + client_secret = "4a788cdfa7f4e71e678f38d7024781fb412f782d" + client_id = "589a43a0032c52da65b4" + redirect_uri = "http://localhost:8000" + + return f""" + + Login with Github + """ + diff --git a/splashgen/templates/github_log_template.html.jinja b/splashgen/templates/github_log_template.html.jinja new file mode 100644 index 0000000..0c2a745 --- /dev/null +++ b/splashgen/templates/github_log_template.html.jinja @@ -0,0 +1,136 @@ + + + + + + + {{ title }} + {% for favicon in favicons %} + + {% endfor %} + + {% if meta %} + + + + + + {% if meta.canonical_url %} + + + {% endif %} + + + + + + + {% if meta.image %} + + + {% endif %} {% endif %} + + + + {% if enable_splashgen_analytics %} + + + + {% endif %} + + +
+ {% if logo %} + + {% endif %} +

+ {{ headline }} +

+
+

+ {{ subtext }} +

+
+ + {% if call_to_action %} + {{ call_to_action }} + {% endif %} + {% if hero_image %} +
+ Image depicting the product +
+ {% endif %} +
+ + diff --git a/splashgen/templates/splash_site.html.jinja b/splashgen/templates/splash_site.html.jinja index 22c94eb..b789feb 100644 --- a/splashgen/templates/splash_site.html.jinja +++ b/splashgen/templates/splash_site.html.jinja @@ -78,6 +78,71 @@ mixpanel.track('site', {'host': window.location.hostname}); {% endif %} + + + +
{% endif %} +
+ +
+ + From 3aed699d147482c7c7302bdbc73a4f3001eacc5a Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Mon, 14 Jun 2021 14:55:49 -0700 Subject: [PATCH 2/5] python APIs --- python-api/base-page.py | 8 ++++++ python-api/create-app.py | 35 +++++++++++++++++++++++ python-api/delete-app-page.py | 31 +++++++++++++++++++++ python-api/home-page.py | 35 +++++++++++++++++++++++ python-api/logged-in-homepage.py | 48 ++++++++++++++++++++++++++++++++ python-api/nav-bar.py | 0 6 files changed, 157 insertions(+) create mode 100644 python-api/base-page.py create mode 100644 python-api/create-app.py create mode 100644 python-api/delete-app-page.py create mode 100644 python-api/home-page.py create mode 100644 python-api/logged-in-homepage.py create mode 100644 python-api/nav-bar.py diff --git a/python-api/base-page.py b/python-api/base-page.py new file mode 100644 index 0000000..46596e8 --- /dev/null +++ b/python-api/base-page.py @@ -0,0 +1,8 @@ +from zenweb import WebPage + +class BasePage(WebPage): + def branding(self): + return { + "primary_color": "#32CBEA", + "secondary_color": "#063F1B" + } \ No newline at end of file diff --git a/python-api/create-app.py b/python-api/create-app.py new file mode 100644 index 0000000..9c39598 --- /dev/null +++ b/python-api/create-app.py @@ -0,0 +1,35 @@ +from base-page import BasePage + + +class CreateAppPage(BasePage): + + def config(self): + return { + "route": "/apps/{self.full_name}/delete" + } + + def render(self): + if LOCAL_STORAGE.jwt_token != None: + return REDIRECT(LoggedInHomePage.ROUTE) + + + response = Request( + "https://cxpme86mmi.execute-api.us-east-2.amazonaws.com/repos", + body={"jwt_token": LOCAL_STORAGE.jwt_token}) + + repo_list = [] + for repo in response.data: + repo_list.append( + { + "name": repo.name, + "branch": repo.default_branch, + "createButton": Request("https://cxpme86mmi.execute-api.us-east-2.amazonaws.com/zenweb-github-create-webhook", body={"repo": repo.full_name}) # URL Param + } + ) + + + return """ + +

Which repo would you like to deploy?

+ {repo_list} + """ \ No newline at end of file diff --git a/python-api/delete-app-page.py b/python-api/delete-app-page.py new file mode 100644 index 0000000..0e856aa --- /dev/null +++ b/python-api/delete-app-page.py @@ -0,0 +1,31 @@ +from base-page import BasePage + + +class DeleteAppPage(BasePage): + + def config(self): + return { + "route": "/apps/{self.full_name}/delete" + } + + def render(self): + if LOCAL_STORAGE.jwt_token != None: + return REDIRECT(LoggedInHomePage.ROUTE) + + + delete_button = """( + +
+
+
+ + + + {% if logo %} {% endif %} -

- {{ headline }} -

-
+
+

+ {{ headline }} +

+
+

{{ subtext }} @@ -191,9 +198,27 @@ />

{% endif %} -
+
+
+
-
+ + + + + + +
From cae083ba637e3d7c35310faee01f571633914b39 Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Fri, 18 Jun 2021 12:51:25 -0700 Subject: [PATCH 4/5] asdasdsa --- splashgen/templates/splash_site.html.jinja | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/splashgen/templates/splash_site.html.jinja b/splashgen/templates/splash_site.html.jinja index 2754b7a..505b3e7 100644 --- a/splashgen/templates/splash_site.html.jinja +++ b/splashgen/templates/splash_site.html.jinja @@ -264,8 +264,10 @@ var url = new URL(window.location.href); var repo = url.searchParams.get("repo"); var selected_app = url.searchParams.get("deployed_app_info"); + var code = url.searchParams.get("code"); - if (localStorage.getItem("jwt_token") && repo === null && selected_app === null) { + + if (localStorage.getItem("jwt_token") && repo === null && selected_app === null && code=== null) { const repoHolder = document.querySelector('#RepoHolder'); repoHolder.innerHTML = "Choose a Repository to deploy a new splashgen site"; @@ -310,9 +312,10 @@ var url = new URL(window.location.href); var repo = url.searchParams.get("repo"); + var code = url.searchParams.get("code"); var selected_app = url.searchParams.get("deployed_app_info"); - if (localStorage.getItem("jwt_token") && selected_app === null && repo === null) { + if (localStorage.getItem("jwt_token") && selected_app === null && repo === null && code !== null) { const deployedAppsHolder = document.querySelector('#DeployedAppsHolder'); deployedAppsHolder.innerHTML = "Deployed Apps"; From bd3fe525dcbe509952cda755cbed478ad048c6b1 Mon Sep 17 00:00:00 2001 From: Daniel Habib Date: Fri, 18 Jun 2021 13:17:46 -0700 Subject: [PATCH 5/5] ASDASDSA --- splashgen/templates/splash_site.html.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/splashgen/templates/splash_site.html.jinja b/splashgen/templates/splash_site.html.jinja index 505b3e7..e974d31 100644 --- a/splashgen/templates/splash_site.html.jinja +++ b/splashgen/templates/splash_site.html.jinja @@ -315,7 +315,7 @@ var code = url.searchParams.get("code"); var selected_app = url.searchParams.get("deployed_app_info"); - if (localStorage.getItem("jwt_token") && selected_app === null && repo === null && code !== null) { + if (localStorage.getItem("jwt_token") && selected_app === null && repo === null && code === null) { const deployedAppsHolder = document.querySelector('#DeployedAppsHolder'); deployedAppsHolder.innerHTML = "Deployed Apps";