Skip to content

Commit 24ee1b0

Browse files
committed
PHP rewrite
1 parent fe45861 commit 24ee1b0

File tree

26 files changed

+669
-605
lines changed

26 files changed

+669
-605
lines changed

.github/workflows/deploy-website.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ jobs:
1414
with:
1515
ref: master
1616

17-
- name: Installing Python
18-
uses: actions/setup-python@v2
17+
- name: Installing PHP
18+
uses: shivammathur/setup-php@v2
1919
with:
20-
python-version: "3.11"
20+
php-version: "8.4"
2121

22-
- name: Installing requirements.txt
23-
run: make install
24-
25-
- name: Compile Flask/Jinja files
22+
- name: Compile PHP files
2623
run: make build
2724

28-
- name: Copy important GitHub Pages files
29-
run: cp ./CNAME ./public/CNAME
30-
3125
- name: Deploy
3226
uses: JamesIves/[email protected]
3327
with:

Makefile

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
1+
SRC_DIR = ./src
2+
OUTPUT_DIR = ./public
3+
FILES = $(filter-out \
4+
$(wildcard $(SRC_DIR)/_*.php) \
5+
$(wildcard $(SRC_DIR)/**/_*.php) \
6+
$(wildcard $(SRC_DIR)/**/**/_*.php), \
7+
$(wildcard $(SRC_DIR)/*.php) \
8+
$(wildcard $(SRC_DIR)/**/*.php) \
9+
$(wildcard $(SRC_DIR)/**/**/*.php) \
10+
)
11+
112
target:
2-
@echo my name jeff
13+
@echo -e "Use 'make \033[0;36mtarget\033[0m' where \033[0;36mtarget\033[0m is one of the following:"
14+
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf " \033[0;36m%-15s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST)
15+
16+
build: ## Build the website
17+
@echo "Generating static HTML files..."
18+
@mkdir -p $(OUTPUT_DIR)
19+
@$(foreach file, $(FILES), \
20+
OUTPUT_PATH=$(OUTPUT_DIR)/$(patsubst $(SRC_DIR)/%,%,$(file)); \
21+
OUTPUT_HTML=$$(echo $$OUTPUT_PATH | sed 's/\.php$$/\.html/'); \
22+
mkdir -p $$(dirname $$OUTPUT_HTML); \
23+
( \
24+
php -f $(file) > $$OUTPUT_HTML 2>/dev/null; \
25+
) || { echo "Error processing $(file)"; exit 1; }; \
26+
echo "Generated $$OUTPUT_HTML"; \
27+
)
28+
29+
@mkdir -p $(OUTPUT_DIR)/static
30+
@cp -r ./static/* $(OUTPUT_DIR)/static
31+
32+
@echo "Copying leftover files..."
33+
@cp -r ./CNAME $(OUTPUT_DIR)
34+
@cp -r ./robots.txt $(OUTPUT_DIR)
35+
@cp -r ./sitemap.xml $(OUTPUT_DIR)
336

4-
install:
5-
pip install -r requirements.txt
37+
@echo "Done."
638

7-
build:
8-
python index.py build
39+
clean: ## Clean the output directory
40+
@echo "Cleaning output directory..."
41+
@rm -rf $(OUTPUT_DIR)
42+
@echo "Done."
943

10-
dev:
11-
python index.py
44+
dev: ## Preview the website locally with PHP
45+
@echo "Previewing locally at http://localhost:8080..."
46+
@php -S localhost:8080 -t $(OUTPUT_DIR)

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# alexflipnote.github.io
2-
This is my personal website that is shown at https://alexflipnote.dev. It works by compiling Jinja2 and then pushing the static files to GitHub Pages using automatic workflows. The website does only use static components, so I take advantage of Jinja2 to make it easier for me to write websites easily with syntaxes.
2+
This is my personal website that is shown at https://alexflipnote.dev.
3+
4+
## How does it work?
5+
This website is built using PHP and static HTML files. When pushing everything, I simply run `make build` which runs a custom-made PHP compiler to generate everything needed while also copying the necessary files to the output directory.
36

47
## Requirements
5-
- Python 3.6 or above
8+
- PHP 8.4 or above
69

710
## License information
811
| Component | License |

index.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Disallow: /src/
3+
4+
Sitemap: https://alexflipnote.dev/sitemap.xml

sitemap.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3+
<url>
4+
<loc>https://alexflipnote.dev/</loc>
5+
<lastmod>2024-12-31</lastmod>
6+
<priority>1.00</priority>
7+
</url>
8+
<url>
9+
<loc>https://alexflipnote.dev/branding</loc>
10+
<lastmod>2024-12-31</lastmod>
11+
<priority>0.90</priority>
12+
</url>
13+
<url>
14+
<loc>https://alexflipnote.dev/playground/hexclock</loc>
15+
<lastmod>2024-12-31</lastmod>
16+
<priority>0.80</priority>
17+
</url>
18+
<url>
19+
<loc>https://alexflipnote.dev/playground/spooky</loc>
20+
<lastmod>2024-12-31</lastmod>
21+
<priority>0.80</priority>
22+
</url>
23+
</urlset>

templates/404.html renamed to src/404.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ <h1 class="bold no-margin">
2727
Page not found<span class="cursor">_</span>
2828
</h1>
2929
<div class="buttons">
30-
<a href="/" class="btn alizarin-bg">Back to home</a>
31-
<a href="#" class="btn emerald-bg" onclick="window.history.go(-1); return false;">Go one step back</a>
30+
<a href="/" class="btn alizarin-bg white-text">Back to home</a>
31+
<a href="#" class="btn emerald-bg white-text" onclick="window.history.go(-1); return false;">Go one step back</a>
3232
</div>
3333
</div>
3434
</section>

src/_templates/_footer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$GITHUB_URL = "https://github.com/AlexFlipnote/alexflipnote.github.io";
3+
?>
4+
5+
<footer class="text-center box-container primary-bg">
6+
<p className="no-margin">
7+
<a href="<?php echo "{$GITHUB_URL}/blob/master/LICENSE"; ?>" target="_blank" rel="noreferrer">LICENSE</a>
8+
<span className="footer-name">AlexFlipnote</span>
9+
<a href="<?php echo "{$GITHUB_URL}"; ?>" target="_blank" rel="noreferrer">Source</a>
10+
</p>
11+
</footer>

templates/components/_head.html renamed to src/_templates/_head.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
{% set URL = 'https://alexflipnote.dev' %}
2-
<title>{{ title or 'default title' }}</title>
1+
<?php
2+
$URL = "https://alexflipnote.dev";
3+
?>
4+
5+
<title><?php echo $title ?? "default title"; ?></title>
36

47
<meta httpEquiv="Content-Type" content="text/html; charset=UTF-8"/>
58
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
69
<meta name="theme-color" content="#14bae4"/>
710
<link rel="icon" type="image/x-icon" href="/static/images/favicon.ico"></link>
811
<meta property="og:image" content="/static/images/branding/avatar.png" />
912

10-
<meta content="{{ title or 'Title' }}" property="og:title"/>
11-
<meta content="{{ desc or 'default description' }}" property="og:description"/>
12-
<meta content="{{ desc or 'default description' }}" name="description"/>
13+
<meta content="<?php echo $title ?? "Title"; ?>" property="og:title"/>
14+
<meta content="<?php echo $desc ?? "default description"; ?>" property="og:description"/>
15+
<meta content="<?php echo $desc ?? "default description"; ?>" name="description"/>
1316

1417
<meta name="revisit-after" content="2 days"/>
1518
<meta name="keywords" content="AlexFlipnote, Twitter, Developer, Github"/>
1619
<meta property="og:locale" content="en_GB"/>
17-
<link rel="canonical" href="{{ URL }}" />
18-
<meta property="og:url" content="{{ URL }}" />
20+
<link rel="canonical" href="<?php echo "{$URL}{$path}"; ?>" />
21+
<meta property="og:url" content="<?php echo "{$URL}{$path}"; ?>" />
1922
<meta property="og:site_name" content="AlexFlipnote"/>
2023
<meta name="twitter:card" content="summary"/>
2124
<meta name="twitter:site" content="@AlexFlipnote"/>

0 commit comments

Comments
 (0)