diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | _data/photos.json | 1 | ||||
-rw-r--r-- | bot/bot.py | 12 | ||||
-rw-r--r-- | site/.well-known/webfinger (renamed from .well-known/webfinger) | 0 | ||||
-rw-r--r-- | site/404.html (renamed from 404.html) | 0 | ||||
-rw-r--r-- | site/CNAME (renamed from CNAME) | 0 | ||||
-rw-r--r-- | site/Gemfile | 5 | ||||
-rw-r--r-- | site/Gemfile.lock (renamed from Gemfile.lock) | 0 | ||||
-rw-r--r-- | site/_config.yml (renamed from _config.yml) | 0 | ||||
-rw-r--r-- | site/_data/.gitkeep | 0 | ||||
-rw-r--r-- | site/_includes/line.html (renamed from _includes/line.html) | 0 | ||||
-rw-r--r-- | site/_layouts/default.html (renamed from _layouts/default.html) | 0 | ||||
-rw-r--r-- | site/_layouts/redirect.html (renamed from _layouts/redirect.html) | 0 | ||||
-rw-r--r-- | site/assets/icon.png (renamed from assets/icon.png) | bin | 25823 -> 25823 bytes | |||
-rw-r--r-- | site/assets/new.scss (renamed from assets/new.scss) | 0 | ||||
-rw-r--r-- | site/assets/site.js (renamed from assets/site.js) | 0 | ||||
-rw-r--r-- | site/assets/syntax.css (renamed from assets/syntax.css) | 0 | ||||
-rw-r--r-- | site/assets/valid-rss-rogers.png (renamed from assets/valid-rss-rogers.png) | bin | 3712 -> 3712 bytes | |||
-rwxr-xr-x | site/build.sh | 4 | ||||
-rw-r--r-- | site/feeds/photos.xml (renamed from feeds/photos.xml) | 0 | ||||
-rw-r--r-- | site/index.html (renamed from index.html) | 0 | ||||
-rw-r--r-- | site/package.json (renamed from package.json) | 0 | ||||
-rwxr-xr-x | site/start (renamed from start) | 0 |
24 files changed, 20 insertions, 10 deletions
@@ -1,4 +1,5 @@ | |||
1 | database/ | 1 | .idea/ |
2 | bot/database/ | ||
2 | env | 3 | env |
3 | _drafts/ | 4 | _drafts/ |
4 | _site/ | 5 | _site/ |
@@ -6,3 +7,4 @@ _site/ | |||
6 | .ruby-version | 7 | .ruby-version |
7 | .jekyll-cache/ | 8 | .jekyll-cache/ |
8 | .venv/ | 9 | .venv/ |
10 | _data/photos.json | ||
diff --git a/Gemfile b/Gemfile deleted file mode 100644 index d770067..0000000 --- a/Gemfile +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | source 'https://rubygems.org' | ||
2 | |||
3 | gem "webrick" | ||
4 | gem 'github-pages', group: :jekyll_plugins | ||
diff --git a/_data/photos.json b/_data/photos.json deleted file mode 100644 index 0a4d8c9..0000000 --- a/_data/photos.json +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | [{"guid": "480EDD16-EC60-4773-96BB-05C5643D6AA7", "fileId": "2023-03-01-00-59-03-IMG_0140.webp", "width": 3548, "height": 5268, "ratio": 0.6735003796507213, "orientation": "portrait", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-59-03-IMG_0140.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:59:03.000Z", "uploadedAt": "2023-03-01T00:59:03.000Z"}, {"guid": "D997B634-063F-4E32-B290-809D53DABFD2", "fileId": "2023-03-01-00-54-08-IMG_0134.webp", "width": 5328, "height": 3548, "ratio": 1.5016910935738443, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-54-08-IMG_0134.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:54:08.000Z", "uploadedAt": "2023-03-01T00:54:08.000Z"}, {"guid": "E3A61BC5-F07C-4681-94B0-AB4CCE4AB843", "fileId": "2023-03-01-00-52-37-IMG_0016.webp", "width": 3548, "height": 5268, "ratio": 0.6735003796507213, "orientation": "portrait", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-52-37-IMG_0016.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:52:37.000Z", "uploadedAt": "2023-03-01T00:52:37.000Z"}, {"guid": "B77DFD0A-342F-41F6-97ED-4FB289149A77", "fileId": "2023-02-28-23-43-55-IMG_0021.webp", "width": 5928, "height": 3992, "ratio": 1.4849699398797596, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-43-55-IMG_0021.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:43:55.000Z", "uploadedAt": "2023-02-28T23:43:55.000Z"}, {"guid": "61881B2D-1B87-4C7B-B4EB-063836F10C90", "fileId": "2023-02-28-23-39-47-IMG_0070.webp", "width": 5280, "height": 3512, "ratio": 1.5034168564920274, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-39-47-IMG_0070.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:39:47.000Z", "uploadedAt": "2023-02-28T23:39:47.000Z"}] \ No newline at end of file | ||
@@ -11,6 +11,7 @@ from peewee import * | |||
11 | from uuid import uuid4 | 11 | from uuid import uuid4 |
12 | from datetime import datetime | 12 | from datetime import datetime |
13 | import json | 13 | import json |
14 | import httpx | ||
14 | 15 | ||
15 | db = SqliteDatabase("database/photos.db") | 16 | db = SqliteDatabase("database/photos.db") |
16 | db.connect(reuse_if_open=True) | 17 | db.connect(reuse_if_open=True) |
@@ -53,6 +54,7 @@ bucket_name = "pixel-jinwei-me" | |||
53 | cf_account_id = os.getenv("CF_ACCOUNT_ID") | 54 | cf_account_id = os.getenv("CF_ACCOUNT_ID") |
54 | aws_access_key_id = os.getenv("CF_R2_KEY_ID") | 55 | aws_access_key_id = os.getenv("CF_R2_KEY_ID") |
55 | aws_secret_access_key = os.getenv("CF_R2_ACCESS_KEY_SECRET") | 56 | aws_secret_access_key = os.getenv("CF_R2_ACCESS_KEY_SECRET") |
57 | cloudflare_pages_deploy_hook_url = os.getenv("CLOUDFLARE_PAGES_DEPLOY_HOOK_URL") | ||
56 | 58 | ||
57 | 59 | ||
58 | def write_json() -> bool: | 60 | def write_json() -> bool: |
@@ -74,8 +76,7 @@ def write_json() -> bool: | |||
74 | "uploadedAt": photo.uploadedAt.strftime("%Y-%m-%dT%H:%M:%S.000Z") | 76 | "uploadedAt": photo.uploadedAt.strftime("%Y-%m-%dT%H:%M:%S.000Z") |
75 | }) | 77 | }) |
76 | results.sort(key=lambda x: x["uploadedAt"], reverse=True) | 78 | results.sort(key=lambda x: x["uploadedAt"], reverse=True) |
77 | with open("database/photos.json", "w") as f: | 79 | upload_to_s3("photos.json", json.dumps(results).encode("utf-8")) |
78 | f.write(json.dumps(results)) | ||
79 | return True | 80 | return True |
80 | 81 | ||
81 | 82 | ||
@@ -155,8 +156,11 @@ async def process(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | |||
155 | upload_to_s3(photo.fileId, output.read()) | 156 | upload_to_s3(photo.fileId, output.read()) |
156 | 157 | ||
157 | write_json() | 158 | write_json() |
158 | await update.message.reply_markdown_v2(text="Done") | 159 | response = httpx.post(cloudflare_pages_deploy_hook_url) |
159 | 160 | if response.status_code == 200: | |
161 | await update.message.reply_markdown_v2(text="trigger deploy succeed") | ||
162 | else: | ||
163 | await update.message.reply_markdown_v2("trigger deploy failed, status: {}".format(response.status_code)) | ||
160 | except Exception: | 164 | except Exception: |
161 | await update.message.reply_markdown_v2(text="Error:\n```{}```".format(traceback.format_exc())) | 165 | await update.message.reply_markdown_v2(text="Error:\n```{}```".format(traceback.format_exc())) |
162 | 166 | ||
diff --git a/.well-known/webfinger b/site/.well-known/webfinger index e69de29..e69de29 100644 --- a/.well-known/webfinger +++ b/site/.well-known/webfinger | |||
diff --git a/site/Gemfile b/site/Gemfile new file mode 100644 index 0000000..46074fc --- /dev/null +++ b/site/Gemfile | |||
@@ -0,0 +1,5 @@ | |||
1 | source 'https://rubygems.org' | ||
2 | |||
3 | gem "webrick" | ||
4 | gem "github-pages", group: :jekyll_plugins | ||
5 | gem "jekyll" | ||
diff --git a/Gemfile.lock b/site/Gemfile.lock index a4ee6d5..a4ee6d5 100644 --- a/Gemfile.lock +++ b/site/Gemfile.lock | |||
diff --git a/_config.yml b/site/_config.yml index 345b52e..345b52e 100644 --- a/_config.yml +++ b/site/_config.yml | |||
diff --git a/site/_data/.gitkeep b/site/_data/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/site/_data/.gitkeep | |||
diff --git a/_includes/line.html b/site/_includes/line.html index 86b7116..86b7116 100644 --- a/_includes/line.html +++ b/site/_includes/line.html | |||
diff --git a/_layouts/default.html b/site/_layouts/default.html index 7ff8d4d..7ff8d4d 100644 --- a/_layouts/default.html +++ b/site/_layouts/default.html | |||
diff --git a/_layouts/redirect.html b/site/_layouts/redirect.html index 3e2238f..3e2238f 100644 --- a/_layouts/redirect.html +++ b/site/_layouts/redirect.html | |||
diff --git a/assets/icon.png b/site/assets/icon.png index f182cc1..f182cc1 100644 --- a/assets/icon.png +++ b/site/assets/icon.png | |||
Binary files differ | |||
diff --git a/assets/new.scss b/site/assets/new.scss index 73c4ed8..73c4ed8 100644 --- a/assets/new.scss +++ b/site/assets/new.scss | |||
diff --git a/assets/site.js b/site/assets/site.js index 4e72511..4e72511 100644 --- a/assets/site.js +++ b/site/assets/site.js | |||
diff --git a/assets/syntax.css b/site/assets/syntax.css index de3ac90..de3ac90 100644 --- a/assets/syntax.css +++ b/site/assets/syntax.css | |||
diff --git a/assets/valid-rss-rogers.png b/site/assets/valid-rss-rogers.png index 8ce6d12..8ce6d12 100644 --- a/assets/valid-rss-rogers.png +++ b/site/assets/valid-rss-rogers.png | |||
Binary files differ | |||
diff --git a/site/build.sh b/site/build.sh new file mode 100755 index 0000000..3ea17f4 --- /dev/null +++ b/site/build.sh | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | curl https://pixelstatic.jinwei.me/photos.json -o _data/photos.json | ||
4 | jekyll build | ||
diff --git a/feeds/photos.xml b/site/feeds/photos.xml index 41ecc5d..41ecc5d 100644 --- a/feeds/photos.xml +++ b/site/feeds/photos.xml | |||
diff --git a/index.html b/site/index.html index 8071de9..8071de9 100644 --- a/index.html +++ b/site/index.html | |||
diff --git a/package.json b/site/package.json index 3dbc1ca..3dbc1ca 100644 --- a/package.json +++ b/site/package.json | |||