-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initialise ssg repository to opensource atasasmaz.com
- Loading branch information
Showing
41 changed files
with
2,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,84 @@ | ||
name: Deploy Website | ||
|
||
on: | ||
push: | ||
branches: | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
packages: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
container: | ||
image: ghcr.io/atas/ssg-builder:latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Restore Composer cache (if exists) | ||
- name: Get Composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
# Install Composer dependencies | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Generate HTML | ||
run: | | ||
system/bin/generate_html.sh | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: 'html' | ||
path: 'html' | ||
|
||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v3 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: 'html' | ||
path: './html' | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
# Upload entire repository | ||
path: 'html' | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 |
This file contains 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 @@ | ||
.DS_Store | ||
.vscode | ||
.idea | ||
html | ||
vendor | ||
assets/styles/*.css | ||
assets/styles/*.css.map |
This file contains 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,21 @@ | ||
# Turn on the rewrite engine | ||
RewriteEngine On | ||
|
||
RewriteCond %{HTTPS} off | ||
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | ||
|
||
RewriteCond %{HTTP_HOST} !^www\. [NC] | ||
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | ||
|
||
# For /page to /page.php?page=page | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^([a-zA-Z0-9-]+)$ /page.php?page=$1 [L] | ||
|
||
# Rewrite /p/something to /post.php?slug=something | ||
RewriteRule ^p/(.*)$ /post.php?slug=$1 [L] | ||
|
||
# For extensionless PHP files | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f | ||
RewriteRule ^(.*?)/?$ $1.php [L] |
This file contains 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,12 @@ | ||
<?php | ||
require_once 'system/bootstrap.php'; | ||
require_once 'layout/header.php'; | ||
?> | ||
|
||
<div class="box"> | ||
<h1>404 Not Found</h1> | ||
<a href='/' class='btn white'>HOME</a> | ||
</div> | ||
|
||
<?php | ||
require_once 'layout/footer.php'; |
This file contains 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,15 @@ | ||
|
||
build-local-image: | ||
docker build system/workflow-image -t atas-ssg-builder:latest | ||
|
||
update-workflow-image: | ||
docker login ghcr.io | ||
docker buildx build --platform linux/amd64 system/workflow-image -t ghcr.io/atas/ssg-builder:latest | ||
docker push ghcr.io/atas/ssg-builder:latest | ||
|
||
|
||
.PHONY: run-local-image | ||
|
||
run-local-image: | ||
docker run --rm -it -v $(shell pwd):/github/workspace atas-ssg-builder:latest | ||
|
This file contains 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,64 @@ | ||
# Ata's SSG - A PHP Static Site Generator | ||
|
||
Harness the power of PHP to create static sites seamlessly for GitHub Pages. With Ata's SSG, there's no need to juggle complex frameworks or master new templating languages. Simply fork, configure, and deploy! | ||
|
||
## Why Ata's SSG? | ||
|
||
* **Simplicity with PHP**: PHP stands as a robust templating and server-side language, eliminating the need to learn new templating languages. | ||
|
||
* **No Framework Learning Curve**: Forget about the learning curve associated with new frameworks or | ||
applications. Familiarity with basic PHP is enough to get started. It's just few files. | ||
|
||
* **Markdown & Beyond**: Craft blog posts or pages with Markdown. Need more complexity? Integrate PHP effortlessly. | ||
|
||
* **Efficient Deployment**: The process is straightforward. Build process visits each PHP and markdown page during, | ||
saves its HTML, and deploy directly to GitHub Pages. | ||
|
||
* **Instant Local Preview**: If you setup a local PHP server, Visualize your changes locally in real-time, ensuring | ||
your | ||
development cycle isn't | ||
hindered by lengthy build times. | ||
|
||
**Disclaimer**: This project is purposefully kept as simple as possible for those just needing to output some HTML | ||
from the simplest PHP files. | ||
|
||
## How to Use | ||
|
||
1. Fork this repository. | ||
2. Update the `config.json` file to your liking. | ||
3. Update images `favicon-96.jpg` `site-icon.jpg` `site-icon-big.jpg` at `./assets/images` | ||
4. Add your pages to ./pages directory in Markdown format. Page URLs are derived from the file name. `my-post.md` | ||
will be | ||
`yoursite.com/my-post` automatically. | ||
5. Add your posts to `./posts` directory in Markdown format. Post URLs are derived from `slug` key in the front matter. | ||
See | ||
the existing examples. | ||
6. Open `layout/footer.php` to add your tracking code if you want, Google Analytics, Matomo (Piwik), etc. | ||
* If using advanced analytics, add a GDPR banner, or use analytics with anonymisation. See my blog post about | ||
more: https://www.atasasmaz.com/p/gdpr-friendly-analytics | ||
7. For changing the layout, see `layout` directory, especially `header.php` and `footer.php`, simple HTML files with | ||
minimal PHP in them. For CSS changes, `less` is used to generate `css` files, see `assets/styles` directory. | ||
8. Follow the below steps to deploy to GitHub Pages. | ||
|
||
## Using GitHub Pages as `https://username.github.io` | ||
|
||
* Your repo name must be `username.github.io` for this to work. Username is github username, lowercase. Rename your | ||
repo. | ||
* Public repos are free, private repos require paid GitHub subscription. | ||
... | ||
TBA | ||
|
||
## Using GitHub Pages through custom domain | ||
... | ||
TBA | ||
|
||
## Local Development without build process | ||
You can use either apache with php or nginx with php-fpm locally to run your site. When run locally, there is no | ||
build process, it's just PHP working server side. | ||
|
||
For Nginx, use the config file in `system/workflow-image/nginx.conf` and follow the comments. | ||
For local Apache, the .htaccess should be enough. | ||
|
||
Ensure local hostname matches the `local_hostname` in `config.json` file. Add it to hosts file at `/etc/hosts` if | ||
necessary. | ||
Locally, http works fine, https is used in build process with self-signed cert to generate URLs correctly. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,106 @@ | ||
//region .non-touch | ||
// Set touch support .nonTouch css class to html element if browser doesn't support touch | ||
let isTouchDevice = true; | ||
const touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0) | ||
if (!touchsupport){ // browser doesn't support touch | ||
document.documentElement.className += " nonTouch" | ||
isTouchDevice = false; | ||
} | ||
//endregion | ||
|
||
let lastScrollTop = 0; | ||
let timer; | ||
const delay = 200; | ||
let originalBodyWidth = window.innerWidth; | ||
|
||
window.addEventListener('scroll', function() { | ||
let currentScrollTop = window.scrollY || document.documentElement.scrollTop; | ||
const header = document.querySelector("#header"); | ||
|
||
if (Math.abs(currentScrollTop - lastScrollTop) <= 200) { | ||
return; | ||
} | ||
|
||
if (currentScrollTop > lastScrollTop && currentScrollTop > header.scrollHeight) { | ||
setScrollingDown(true); | ||
} | ||
else { | ||
setScrollingDown(false); | ||
} | ||
|
||
lastScrollTop = currentScrollTop; | ||
|
||
}, {passive: true}); | ||
|
||
function setScrollingDown(yes) { | ||
const header = document.querySelector("#header"); | ||
if (yes === true && header.classList.contains("scrollingDown") === false) { | ||
header.classList.add("scrollingDown"); | ||
} | ||
else if (yes === false && header.classList.contains("scrollingDown") === true) { | ||
header.classList.remove("scrollingDown"); | ||
} | ||
} | ||
|
||
function setBodyWrapperMarginTop() { | ||
const bodyWrapper = document.querySelector("#bodyWrapper"); | ||
bodyWrapper.style.marginTop = (document.querySelector("#header").scrollHeight) + 'px'; | ||
originalBodyWidth = window.innerWidth; | ||
} | ||
|
||
// on window resize | ||
window.addEventListener('resize', function () { | ||
if (originalBodyWidth !== document.body.clientWidth) { | ||
setBodyWrapperMarginTop(); | ||
} | ||
}); | ||
|
||
|
||
window.addEventListener('load', function () { | ||
setBodyWrapperMarginTop(); | ||
|
||
//region Insert site email address into all .email elements | ||
const emails = document.getElementsByClassName('email') | ||
const addr = email_local + '@' + email_domain; | ||
for (let email of emails) { | ||
email.innerHTML = "<a href='mailto:"+addr+"' class='emailAddress'>"+addr+"</a>"; | ||
} | ||
//endregion | ||
|
||
if (isTouchDevice) { | ||
document.querySelectorAll('a').forEach(function (a) { | ||
a.addEventListener('click', event => { | ||
a.classList.add('active'); | ||
setTimeout(function () { | ||
a.classList.remove('active'); | ||
}, 300); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
window.addEventListener('DOMContentLoaded', function() { | ||
setBodyWrapperMarginTop(); | ||
|
||
// Find all anchor links on the page | ||
const anchorLinks = document.querySelectorAll('a[href^="#"]:not([href="#"])'); | ||
|
||
anchorLinks.forEach(link => { | ||
link.addEventListener('click', function(event) { | ||
event.preventDefault(); // Stop the default anchor behavior | ||
|
||
const targetId = this.getAttribute('href'); // e.g., "#heading" | ||
const targetElement = document.querySelector(targetId); | ||
|
||
if (targetElement) { | ||
const rect = targetElement.getBoundingClientRect(); | ||
const absoluteTop = window.pageYOffset + rect.top - document.querySelector("#header").scrollHeight; | ||
|
||
window.scrollTo({ | ||
top: absoluteTop, | ||
behavior: "smooth" // Smooth scrolling | ||
}); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.