Skip to content

Commit 85af180

Browse files
authored
Merge pull request #54 from samliew/copilot/refactor-codebase-for-vercel
Deploy site to Vercel.
2 parents 7832e5c + 8c23439 commit 85af180

8 files changed

Lines changed: 70 additions & 25 deletions

File tree

.github/workflows/main.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
name: Glitch Deploy
1+
# Vercel handles deployments automatically via its Git integration.
2+
# Connect this repo to a Vercel project at: https://vercel.com/new
3+
# See: https://vercel.com/docs/deployments/git
4+
#
5+
# This workflow is intentionally left as a placeholder.
6+
# You can safely delete this file once Vercel deployment is confirmed working.
27

3-
# Glitch Project: https://glitch.com/edit/#!/se-timeline
4-
# Get Glitch token: (JSON.parse(localStorage.getItem('cachedUser'))).persistentToken
8+
name: Deploy Info
59

610
on:
711
push:
812
branches:
913
- main
1014

1115
jobs:
12-
sync:
16+
info:
1317
runs-on: ubuntu-latest
1418
steps:
15-
- name: Deploy to Glitch Project
16-
uses: kanadgupta/glitch-sync@main
17-
with:
18-
auth-token: "${{ secrets.glitch_auth_token }}"
19-
project-id: "${{ secrets.glitch_project_id }}"
19+
- name: Deployment note
20+
run: echo "This site is deployed to Vercel automatically via Git integration."

.github/workflows/validate-json.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ on:
44
pull_request:
55
paths:
66
- "**.json"
7+
- "!.vscode/**"
78

89
jobs:
910
test:
1011
name: Validate JSON
1112
runs-on: ubuntu-latest
1213
steps:
13-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v5
1415
- name: json-syntax-check
15-
uses: limitusus/json-syntax-check@v2
16-
with:
17-
pattern: "\\.json$"
16+
run: |
17+
status=0
18+
for f in $(find . -name '*.json' -not -path './.git/*' -not -path './.vscode/*'); do
19+
if ! python3 -m json.tool "$f" > /dev/null 2>&1; then
20+
echo "❌ Invalid JSON: $f"
21+
python3 -m json.tool "$f" || true
22+
status=1
23+
else
24+
echo "✅ Valid JSON: $f"
25+
fi
26+
done
27+
exit $status

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version.txt

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
# The Stack Exchange Timeline
22

3-
[![Glitch Deploy](https://github.com/samliew/se-timeline/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/samliew/se-timeline/actions/workflows/main.yml) [![Licence](https://img.shields.io/github/license/samliew/se-timeline?color=blue)](https://github.com/samliew/se-timeline/blob/main/LICENCE) [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/samliew/se-timeline)](https://github.com/samliew/se-timeline/pulse)
3+
[![Build](https://github.com/samliew/se-timeline/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/samliew/se-timeline/actions/workflows/main.yml) [![Validation](https://github.com/samliew/se-timeline/actions/workflows/validate-json.yml/badge.svg)](https://github.com/samliew/se-timeline/actions/workflows/validate-json.yml)
4+
[![Licence](https://img.shields.io/github/license/samliew/se-timeline?color=blue)](https://github.com/samliew/se-timeline/blob/main/LICENCE) [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/samliew/se-timeline)](https://github.com/samliew/se-timeline/pulse)
45

5-
This is currently hosted on [Glitch](https://glitch.com), at [se-timeline.glitch.me](https://se-timeline.glitch.me).
6+
This is a static site deployed to [Vercel](https://vercel.com). Pushing to the `main` branch triggers an automatic deployment via Vercel's Git integration.
67

78
## Contributing
89

910
Please direct any queries & feedback by [creating an issue on GitHub](https://github.com/samliew/se-timeline/issues).
1011

11-
You can also contribute to updating the events using the instructions below, then opening a pull request. After review and merging to the main branch, a GitHub action will then automatically update the Glitch project.
12-
13-
Don't worry about making mistakes, a GitHub action will run on any pull request to validate changes to the JSON file, and the PR can only be merged if it passes.
12+
You can also contribute to updating the events using the instructions below, then opening a pull request. After review and merging to the main branch, Vercel will automatically deploy the updated site. Don't worry about making mistakes—a GitHub action will run on pull requests to validate changes to the JSON file, and the changes can only be merged if it passes.
1413

1514
### Updating Events
1615

1716
The timeline data is stored in the [timeline_data.json](https://github.com/samliew/se-timeline/blob/main/timeline_data.json) file as JSON.
1817

19-
If you are unsure how to manually edit the event data using JSON, you should use the [Event Editor](https://se-timeline.glitch.me/event-editor) to import an existing event or create a new one, following which you can paste the output in a new "Update Timeline" [issue](https://github.com/samliew/se-timeline/issues/new/choose).
18+
If you are unsure how to manually edit the event data using JSON, you should use the [Event Editor](/event-editor) to import an existing event or create a new one, following which you can paste the output in a new "Update Timeline" [issue](https://github.com/samliew/se-timeline/issues/new/choose).
2019

2120
### Event Object Properties
2221

assets/js/editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ const toSlug = str => str?.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-
395395
if (linkedDropdown && importDropdown) {
396396
let currentYear;
397397

398-
const { items } = await $.getJSON('/timeline_data.json');
398+
const version = await fetch('/version.txt').then(r => r.ok ? r.text() : '').then(t => t.trim()).catch(() => '');
399+
const { items } = await $.getJSON('/timeline_data.json' + (version ? '?v=' + version : ''));
399400
items.forEach(event => {
400401

401402
// Assumes items are already sorted by year

assets/js/script.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ const buildTimeline = async () => {
117117
const timelineEl = document.querySelector('#timeline > .events-container');
118118
timelineEl.querySelectorAll('.year-group').forEach(v => v.remove());
119119

120-
const { items } = await $.getJSON('./timeline_data.json');
120+
const version = await fetch('./version.txt').then(r => r.ok ? r.text() : '').then(t => t.trim()).catch(() => '');
121+
const { items } = await $.getJSON('./timeline_data.json' + (version ? '?v=' + version : ''));
121122
items.forEach(event => {
122123

123124
// Assumes items are already sorted by year

index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ <h1 class="main-title mobile-only">SE Timeline</h1>
3636
</a>
3737
<div class="header-right">
3838
<div>
39-
<select id="year-picker" class="year-picker w-select">
40-
<option>2021</option>
41-
</select>
39+
<select id="year-picker" class="year-picker w-select"></select>
4240
</div>
4341
</div>
4442
</header>
45-
<aside id="sidebar" class="sidebar sidebar-open"><a href="#" class="current-year">2021</a><a href="#">2020</a><a href="#">2019</a><a href="#">2018</a><a href="#">2017</a><a href="#">2016</a><a href="#">2015</a><a href="#">2014</a><a href="#">2013</a><a href="#">2012</a><a href="#">2011</a><a href="#">2010</a><a href="#">2009</a><a href="#">2008</a></aside>
43+
<aside id="sidebar" class="sidebar"></aside>
4644
<aside class="filter-container">
4745
<div class="filter-section-title">show:</div>
4846
<div class="filters">

vercel.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"cleanUrls": true,
3+
"trailingSlash": false,
4+
"buildCommand": "echo ${VERCEL_GIT_COMMIT_SHA:-dev} > version.txt",
5+
"headers": [
6+
{
7+
"source": "/assets/(.*)",
8+
"headers": [
9+
{
10+
"key": "Cache-Control",
11+
"value": "public, max-age=31536000, immutable"
12+
}
13+
]
14+
},
15+
{
16+
"source": "/timeline_data.json",
17+
"headers": [
18+
{
19+
"key": "Cache-Control",
20+
"value": "public, max-age=31536000, immutable"
21+
}
22+
]
23+
},
24+
{
25+
"source": "/version.txt",
26+
"headers": [
27+
{
28+
"key": "Cache-Control",
29+
"value": "public, max-age=0, must-revalidate"
30+
}
31+
]
32+
}
33+
]
34+
}

0 commit comments

Comments
 (0)