This repository was archived by the owner on Jul 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Add svelte #99
Draft
cofob
wants to merge
103
commits into
master
Choose a base branch
from
cofob/svelte
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add svelte #99
Changes from all commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
49107ab
Svelte & Bulma = ♥
cofob 1a0fce9
Update
cofob 5025607
Add logo
cofob fe01fcd
Add Modal.svelte
cofob 0afb111
Merge branch 'master' into cofob/svelte
PerchunPak 4ace3ab
Update
cofob ac0f425
Add deduplication and pay url generation to Donate
cofob 18aa5c8
Add fancy Donate buttons
cofob 5da2345
Fix pay_url generation
cofob 0bc4e0a
Fix pay button disabled state
cofob 76771db
add about button to donate
cofob c8de115
move +/- buttons
cofob 8f78625
Fix tests
cofob 1ce242b
Fix docstring
cofob e35dbad
Fix typo
cofob 9389935
Remove useless files
cofob 5b5a6ab
More
cofob 6c7a716
Add Svelte CI/CD (#105)
cofob 7f64867
Squashed commit of the following:
cofob 739cfa3
Merge branch 'cofob/svelte' of github.com:fire-square/autodonate into…
cofob 2ac97fe
Add docs
cofob c60856b
Fix cofob's docstrings
PerchunPak fd6f9a8
Move dataclasses to DB models
PerchunPak 5daa1b0
Add player model
cofob 8b40130
Add media files serve for FileField
cofob 7c5023f
Remove ugly defenition
cofob e64cbc3
Fix typo
cofob 7805bae
Remove bulma from staticfiles dir
cofob 28928da
Upgrade models
cofob 24009d1
Register models in admin
cofob f79d512
Add media folder to gitignore
cofob 01d1c0b
Uodate
cofob 6ea72a5
Change to ImageField
cofob 92b89ae
Fix tests
cofob 9be8c94
Fix UUID generation
cofob f7e766e
Update :)
cofob 04ab415
Add modal, remove about section
cofob 9018b80
Normal toasts
cofob a114d7f
Add about anchor
cofob 67b1e16
Remove old toast from base.html
cofob 8fe6fa0
Working modal (broken backdrop)
cofob 6f6cb86
Impemented about for Donate
cofob f7465a2
Fix pay url generation
cofob 775af75
Fix warn
cofob 7109fcb
Use POST instead of GET request for pay button
cofob 49d445b
Fix ci
cofob df8881f
Add empty stubs
cofob d58851b
Add comments
cofob aa0e8e1
More comments
cofob 514d093
Add dot
cofob 6fef82b
Typo
cofob 2d84ea8
Add handler to `urlpatterns` with decorator
PerchunPak 84be612
Add TokenField
cofob 900915a
Merge remote-tracking branch 'origin/cofob/svelte' into cofob/svelte
cofob 5a81626
Fix mypy
cofob 8b32a13
Add docstring
cofob 8a2e9e1
Make API return true JSON
PerchunPak 182b6b8
Add djangorestframework
cofob 310d332
Move docs deps to dev section
cofob a93cc70
Changed to REST API framework
cofob 28f3152
Fix svelte widgets
cofob 1e3bcfc
Add rate limits
cofob fe96863
Fix
cofob 5efea1e
Fix z-index toast
cofob 9fa9eac
Revert "Move docs deps to dev section"
cofob 7493b09
Fix warnings
cofob 23e4d67
Use special svelte file for index page
cofob b2a281a
Fix btn on mobile
cofob 66947d6
Md support for Modals & Donate about section
cofob 8c6d366
Merge branch 'master' into cofob/svelte
PerchunPak 86df07f
Migrate to TypeScript
PerchunPak 4950e52
Replace tabs to spaces
PerchunPak d442b6f
Revert "Migrate to TypeScript"
cofob 9a00cc5
Revert "Revert "Migrate to TypeScript""
PerchunPak f23432b
Fix all TypeScript errors
PerchunPak 1f7f456
Merge branch 'master' into cofob/svelte
cofob 84a4204
Add screenshot action (#116)
cofob df90e36
Fix tsconfig
cofob 60c5f3c
Fix screenshot.yml
PerchunPak e997f2c
Apply black changes
PerchunPak 2e0c50e
Revert "Fix tsconfig"
PerchunPak 4bfa1ec
Remove DEBUG=false in screenshot.yml
PerchunPak c604c11
Merge branch 'master' into cofob/svelte
PerchunPak f35c207
Fix RelationsFields in the API (#118)
PerchunPak be71b14
Fix action
cofob 86e36c1
Update poetry.lock
PerchunPak 12e60ed
Add public config fields
cofob 86c32d6
Merge branch 'cofob/svelte' of github.com:fire-square/autodonate into…
cofob 7fa0dec
Change __str__ docs
cofob 1b6e3f0
Add product groups
cofob acc5377
Replace `django-svelte` with custom file (#120)
PerchunPak 51ab332
update
cofob 12bd659
Remove migrations
cofob ec276ac
Update readme
cofob 1da148f
Add sleep to screenshot.py
cofob e371836
Update action
cofob 0f40a54
Remove ubjson
cofob 28d6a46
Customize svelte css class name
cofob 67f97d4
Update screenshot action (#123)
cofob e8b3b51
Reduce js usage
cofob 734cd12
Merge branch 'master' into cofob/svelte
PerchunPak b923a88
Update poetry.lock
PerchunPak edc03ea
Merge branch 'master' into cofob/svelte
cofob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """Script for generating screenshots of the main page in ``.github/workflows/screenshot.yml``.""" | ||
|
|
||
| import re | ||
| from base64 import b64encode | ||
| from json import loads | ||
| from subprocess import check_output | ||
| from time import sleep | ||
| from typing import Dict, List | ||
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.chrome.options import Options | ||
| from selenium.webdriver.chrome.service import Service | ||
| from selenium.webdriver.common.by import By | ||
| from webdriver_manager.chrome import ChromeDriverManager | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Main function of the script.""" | ||
| # Blacklist url regex expression | ||
| expr = re.compile(r".*(auth|login|__|<|>|api).*") | ||
| # Blacklist | ||
| blacklist: List[str] = [] | ||
|
|
||
| # Load all urlpatterns | ||
| urls: List[Dict[str, str]] = loads(check_output("poetry run python manage.py show_urls -uf json".split()).decode()) | ||
|
|
||
| # Initialize Chrome (pre-installed on GitHub Actions machine) | ||
| chrome_options = Options() | ||
| chrome_options.add_argument("--headless") | ||
| # Download appropriate driver version for Chrome | ||
| driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) | ||
|
|
||
| # Iterate over screen widths | ||
| for width in [1920, 720, 640, 480, 360]: | ||
| # Iterate over all urls in urlpatterns | ||
| for url in urls: | ||
| # Check if url in blacklist | ||
| if url["url"] in blacklist: | ||
| continue | ||
|
|
||
| # Check if url contains url arguments. Drop if hit. | ||
| if expr.findall(url["url"].lower()): | ||
| # Add to blacklist | ||
| blacklist.append(url["url"]) | ||
| continue | ||
|
|
||
| # Get page | ||
| driver.get("http://localhost:8000" + url["url"]) | ||
|
|
||
| # Sleep 1 second, wait for redirects | ||
| sleep(1) | ||
|
|
||
| # Check if url contains url arguments. Drop if hit. | ||
| if expr.findall(driver.current_url.lower()): | ||
| # Add to blacklist | ||
| blacklist.append(url["url"]) | ||
| continue | ||
|
|
||
| # Set window size to page size (fullpage screenshot) | ||
| driver.set_window_size(width, driver.execute_script("return document.body.parentNode.scrollHeight")) | ||
|
|
||
| # Sleep more to ensure full page load | ||
| sleep(2) | ||
|
|
||
| # Save screenshot of body element, avoid scrollbar | ||
| driver.find_element(by=By.TAG_NAME, value="body").screenshot( | ||
| f"screenshot-{b64encode((url['url'] + ' (width: ' + str(width) + ')').encode()).decode()}.png" | ||
| ) | ||
|
|
||
| # Properly close Chrome | ||
| driver.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """Script for uploading screenshots to public storage.""" | ||
|
|
||
| from base64 import b64decode | ||
| from glob import glob | ||
| from sys import argv | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| def main(secret_key: str, commit: str) -> str: | ||
| """Main function to upload screenshots. | ||
|
|
||
| Args: | ||
| secret_key: Secret key for uploading. Passing directly to API. | ||
| commit: Commit where screenshot was taken. | ||
|
|
||
| Returns: | ||
| Link to uploaded screenshots. | ||
| """ | ||
| for image in glob("screenshot-*.png"): | ||
| response = requests.post( | ||
| "https://screen.deta.dev/upload", | ||
| data={"secret": secret_key, "key": commit, "comment": b64decode(image[11:-4]).decode()}, | ||
| files={"file": open(image, "rb")}, | ||
| ) | ||
|
|
||
| return "https://screen.deta.dev/" + response.json()["key"] | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print(main(argv[1], argv[2])) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """API app.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """App module for API app.""" | ||
|
|
||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class ApiConfig(AppConfig): | ||
| """API configuration.""" | ||
|
|
||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "api" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| """URL patterns for API app.""" | ||
|
|
||
| from typing import List | ||
|
|
||
| from django.urls import include, path | ||
| from django.urls.resolvers import URLPattern | ||
| from rest_framework import generics, mixins, routers, serializers, viewsets | ||
|
|
||
| from api.views import urls | ||
| from autodonate.models import Config, Donation, Player, Product | ||
|
|
||
|
|
||
| class ConfigSerializer(serializers.HyperlinkedModelSerializer): | ||
| """Serializer for Config model.""" | ||
|
|
||
| class Meta: | ||
| """Meta class.""" | ||
|
|
||
| model = Config | ||
| fields = ["key", "value", "read_only"] | ||
|
|
||
|
|
||
| class ConfigViewSet(viewsets.ModelViewSet): | ||
| """Config viewset model.""" | ||
|
|
||
| queryset = Config.objects.filter(public=True) | ||
| serializer_class = ConfigSerializer | ||
|
|
||
|
|
||
| class ProductSerializer(serializers.HyperlinkedModelSerializer): | ||
| """Serializer for Product model.""" | ||
|
|
||
| class Meta: | ||
| """Meta class.""" | ||
|
|
||
| model = Product | ||
| fields = ["id", "name", "price", "long_description", "group", "max_in_cart", "image"] | ||
|
|
||
|
|
||
| class ProductViewSet(viewsets.ModelViewSet): | ||
| """Product viewset model.""" | ||
|
|
||
| queryset = Product.objects.filter(enabled=True) | ||
| serializer_class = ProductSerializer | ||
|
|
||
|
|
||
| class PlayerSerializer(serializers.HyperlinkedModelSerializer): | ||
| """Serializer for Player model.""" | ||
|
|
||
| class Meta: | ||
| """Meta class.""" | ||
|
|
||
| model = Player | ||
| fields = ["nickname"] | ||
|
|
||
|
|
||
| class PlayerViewSet(generics.RetrieveAPIView, viewsets.GenericViewSet): | ||
| """Viewset for Player model.""" | ||
|
|
||
| queryset = Player.objects.all() | ||
| serializer_class = PlayerSerializer | ||
|
|
||
|
|
||
| class DonationSerializer(serializers.HyperlinkedModelSerializer): | ||
| """Serializer for Donation model.""" | ||
|
|
||
| product = ProductSerializer(read_only=True) | ||
| player = PlayerSerializer(read_only=True) | ||
|
|
||
| class Meta: | ||
| """Meta class.""" | ||
|
|
||
| model = Donation | ||
| fields = ["id", "product", "player", "date"] | ||
|
|
||
|
|
||
| class DonationViewSet(viewsets.ModelViewSet): | ||
| """Serializer for Donation model.""" | ||
|
|
||
| queryset = Donation.objects.filter(product__enabled=True)[:6] | ||
| serializer_class = DonationSerializer | ||
|
|
||
|
|
||
| router = routers.DefaultRouter() | ||
| router.register(r"config", ConfigViewSet) | ||
| router.register(r"product", ProductViewSet) | ||
| router.register(r"player", PlayerViewSet) | ||
| router.register(r"donation", DonationViewSet) | ||
|
|
||
| urlpatterns: List[URLPattern] = [ | ||
| path("", include(router.urls)), | ||
| ] | ||
|
|
||
| urlpatterns.extend(urls) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| """Views module for index app.""" | ||
|
|
||
| from typing import List | ||
|
|
||
| from django.urls.resolvers import URLPattern | ||
|
|
||
| urls: List[URLPattern] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если это не заставляет иметь зависимость
node.jsв рантайме, зачем пользователя заставлять компилировать? Как на счет добавить пре-компилированные файлы для моментального запуска в проде? (Это будет стороннее изменение, так что не в этом PR, просто обсуждение)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, можно распространять скомпилированные файлы в релизах и докерах.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved?