aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Gemfile4
-rw-r--r--_data/photos.json1
-rw-r--r--bot/bot.py12
-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/Gemfile5
-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/.gitkeep0
-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)bin25823 -> 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)bin3712 -> 3712 bytes
-rwxr-xr-xsite/build.sh4
-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-xsite/start (renamed from start)0
24 files changed, 20 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index afd5147..fbc84df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
1database/ 1.idea/
2bot/database/
2env 3env
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 @@
1source 'https://rubygems.org'
2
3gem "webrick"
4gem '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
diff --git a/bot/bot.py b/bot/bot.py
index f379e95..90b8141 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -11,6 +11,7 @@ from peewee import *
11from uuid import uuid4 11from uuid import uuid4
12from datetime import datetime 12from datetime import datetime
13import json 13import json
14import httpx
14 15
15db = SqliteDatabase("database/photos.db") 16db = SqliteDatabase("database/photos.db")
16db.connect(reuse_if_open=True) 17db.connect(reuse_if_open=True)
@@ -53,6 +54,7 @@ bucket_name = "pixel-jinwei-me"
53cf_account_id = os.getenv("CF_ACCOUNT_ID") 54cf_account_id = os.getenv("CF_ACCOUNT_ID")
54aws_access_key_id = os.getenv("CF_R2_KEY_ID") 55aws_access_key_id = os.getenv("CF_R2_KEY_ID")
55aws_secret_access_key = os.getenv("CF_R2_ACCESS_KEY_SECRET") 56aws_secret_access_key = os.getenv("CF_R2_ACCESS_KEY_SECRET")
57cloudflare_pages_deploy_hook_url = os.getenv("CLOUDFLARE_PAGES_DEPLOY_HOOK_URL")
56 58
57 59
58def write_json() -> bool: 60def 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/404.html b/site/404.html
index 3b25d38..3b25d38 100644
--- a/404.html
+++ b/site/404.html
diff --git a/CNAME b/site/CNAME
index fbffb78..fbffb78 100644
--- a/CNAME
+++ b/site/CNAME
diff --git a/site/Gemfile b/site/Gemfile
new file mode 100644
index 0000000..46074fc
--- /dev/null
+++ b/site/Gemfile
@@ -0,0 +1,5 @@
1source 'https://rubygems.org'
2
3gem "webrick"
4gem "github-pages", group: :jekyll_plugins
5gem "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
3curl https://pixelstatic.jinwei.me/photos.json -o _data/photos.json
4jekyll 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
diff --git a/start b/site/start
index e6bda98..e6bda98 100755
--- a/start
+++ b/site/start
Powered by cgit v1.2.3 (git 2.41.0)