-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from sebastianks/sebastianks/issue32
Completely re-write Volcano
- Loading branch information
Showing
36 changed files
with
2,596 additions
and
1,057 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,14 @@ | ||
name: CS Fixer | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
php-cs-fixer: | ||
name: PHP-CS-Fixer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: PHP-CS-Fixer | ||
uses: docker://oskarstark/php-cs-fixer-ga | ||
with: | ||
args: . |
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,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
vendor/ | ||
composer.lock | ||
.idea | ||
NUL | ||
.vscode |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
<?php | ||
|
||
namespace Volcano\Models; | ||
|
||
use Volcano\Volcano; | ||
|
||
interface IEntry | ||
{ | ||
public function link(): string; | ||
public function meta(string $type): string; | ||
} | ||
|
||
/** | ||
* Class Entry | ||
* The Entry Model | ||
* @package Volcano\Models | ||
*/ | ||
class Entry extends Volcano implements IEntry | ||
{ | ||
/** | ||
* The path to the directory where the Entry is located. | ||
* @var string $path | ||
*/ | ||
protected string $path; | ||
|
||
public function __construct( | ||
public string $file = '', | ||
) { | ||
$this->path = strpos($file, $this->getPath('posts')) | ||
? $this->getPath('posts') | ||
: $this->getPath('pages'); | ||
} | ||
|
||
/** | ||
* Generate an Entry link. | ||
* Removes the directory path and file extension. | ||
* @return string | ||
*/ | ||
public function link(): string | ||
{ | ||
$noDirectoryName = explode('/', str_replace($this->path, '', $this->file)); | ||
return str_replace('.md', '', str_replace('\\', '/', end($noDirectoryName))); | ||
} | ||
|
||
/** | ||
* Get meta data. | ||
* @param string $type | ||
* @return string | ||
*/ | ||
public function meta(string $type): string | ||
{ | ||
return $this->getMeta($type, $this); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,158 +1,53 @@ | ||
# Volcano | ||
# Volcano 🌋 | ||
|
||
An extendable & lightweight flat file blog and website constructor. | ||
A micro flat-file blog and website constructor. | ||
|
||
## Features | ||
|
||
- No database | ||
- Lightweight, extendable & fast | ||
- You write your content in beautiful markdown | ||
- Easy-to-use plugin environment | ||
- Great with custom designs | ||
- No database | ||
- Fast | ||
- Easy to use | ||
- You write your content in beautiful Markdown | ||
- Great with custom designs | ||
|
||
## Requirements | ||
|
||
A server running PHP 7 or higher. | ||
- PHP 8.0.0 or higher | ||
- Support for `mod_rewrite` ([how to set up](https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite)) | ||
|
||
Might run on older PHP versions but those are not tested. | ||
|
||
## Get started | ||
## Getting Started | ||
|
||
```bash | ||
mkdir ~/path/to/project | ||
cd ~/path/to/project | ||
|
||
composer require sebastianks/volcano | ||
|
||
# IMPORTANT | ||
# copy initial configuration and site to your project | ||
# if you don't do this you *have* to set these things up manually. | ||
# NOTE: The copy method might vary from OS | ||
cd ~/path/to/project/ | ||
# Copy a slim starter template bundled with Volcano. | ||
cp -r vendor/sebastianks/volcano/setup/* . | ||
``` | ||
|
||
Easy, right? | ||
|
||
### Wanna get started even quicker? | ||
|
||
You can try one of the official templates available. This gives you opinionated and up-to-date templates that will get you started right away. Found an issue with a template? Please, submit an issue on the corresponding repository. | ||
|
||
- [Blog](https://github.com/sebastianks/volcano-blog-template) | ||
|
||
## Posts | ||
|
||
Write blog posts in an easy and straightforward way with Posts. All you do is put your Markdown files in the `/site/posts/` directory and you are good to go! | ||
|
||
Organize your posts in sub-directories like so: | ||
|
||
```bash | ||
site | ||
posts | ||
sub1 | ||
my-post-in-sub1.md | ||
sub2 | ||
another-nested-post.md | ||
this-is-second-post.md | ||
post-not-in-sub.md | ||
another-not-in-sub-post.md | ||
``` | ||
|
||
Which will allow you to access posts like this: | ||
|
||
```bash | ||
site/posts/sub1/my-post-in-sub1.md -> /sub1/my-post-in-sub1 | ||
site/posts/post-not-in-sub.md -> /post-not-in-sub | ||
``` | ||
|
||
## Meta data | ||
|
||
Both pages and posts enables you to add meta data like title, description and keywords directly in the Markdown file like this: | ||
|
||
```md | ||
<!-- | ||
* Title: My blog post | ||
* Description: I am just a regular blog post. | ||
--> | ||
|
||
## My blog post | ||
``` | ||
|
||
These can easily be retrieved with the helper method [site_meta](https://github.com/sebastianks/volcano/blob/master/core/meta.php#L10) to use in your theme like so: | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Volcano — <?php site_meta('title', true); ?></title> | ||
<meta name="description" content="<?php site_meta('description', true); ?>" /> | ||
</head> | ||
<body class="<?php body_class(); ?>"></body> | ||
</html> | ||
``` | ||
|
||
## Theming | ||
|
||
There are some minimum requirements for your theme to run. That is: | ||
|
||
- The `theme` folder in `/site/` (obviously) | ||
- Inside `/site/theme` you need the following files: | ||
- header.php | ||
- footer.php | ||
- index.php | ||
- That's it! | ||
|
||
### Templates | ||
|
||
A template is a file that let's you create a custom layout for a specific page on your site. | ||
|
||
Templates live in a folder in `/site/theme/` called `/templates`. A template file equals the page name. | ||
Page `yoursite.com/about-me` requires a template file called `about-me.php`. | ||
Volcano will now serve your app from `/site/theme/index.php` which at it's lightest can be as slim as: | ||
|
||
### Partials | ||
```php | ||
<?php | ||
|
||
In addition to templates you have partials. A partial is a piece of code that you find yourself reusing. | ||
|
||
Partials live in a folder in `/site/theme` called `/partials`. Partial names should be a-Z, 0-9 and `.php` files. | ||
To use a partial in your theme you call it by filename without `.php`. Example: `<?php get_partial('partial-name'); ?>`. | ||
|
||
### CSS & JS | ||
|
||
All `.css` and `.js` files in `/site/theme` and `/site/plugins` are automatically loaded. | ||
The only thing you have to do is use `get_stylesheets()` and `get_scripts()`. Example: | ||
# Get our App instance | ||
$app = require __DIR__ . '/../../app.php'; | ||
|
||
# This is where the magic happens 🧙♂️ | ||
echo $app->render(); | ||
``` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<?php get_stylesheets(); ?> | ||
</head> | ||
<body> | ||
... | ||
<?php get_scripts(); ?> | ||
</body> | ||
</html> | ||
``` | ||
|
||
Each file will be loaded and added to the DOM individually one after another. | ||
|
||
## Plugins | ||
|
||
Plugins in Volcano is easy to build and easy to use. | ||
|
||
Plugins are basically a function that executes upon calling `plugin('plugin-name')` which could create a Facebook widget, a gallery or something else. | ||
|
||
The requirements for a plugin is: | ||
|
||
- A folder inside `/site/plugins/` where your plugin lives. Example: `/site/plugins/google-analytics/` | ||
- Inside that folder you need at least `index.php` | ||
- `index.php` requires a function with the same name as the folder _but_ in camelCase. Example: `function googleAnalytics() { ... }` | ||
That is Volcano at it's barebones. A more realistic real-life example can be found [in the Wiki](https://github.com/sebastianks/volcano/wiki/The-Simple-Starter). | ||
|
||
To call a plugin from your theme files use: | ||
## What's next? | ||
|
||
`plugin('google-analytics');` | ||
You just created your first app with Volcano🎉 Now you can go ahead and make a beautiful theme, start composing some content or something else you fancy. It's all up to you. | ||
|
||
The `plugin()` function takes two arguments. First is the name. Second argument is passed to the plugin root function, like: `googleAnalytics($id)`. The second argument is used to pass options to your plugin. This could be a single value, like in this case, an id, or an array of options. `$options` is default to `false`, and is not needed if your plugin doesn't need it. | ||
A couple of resources if you need some information and/or inspiration: | ||
|
||
Your plugin can have `.css` and `.js` files, and will automatically be added to the front-end. Read the section "CSS & JS" for more information. | ||
- Read the [Wiki](https://github.com/sebastianks/volcano/wiki/Home%F0%9F%8C%8B). It's short and will get you started in no time. | ||
- Volcano has a well-documented codebase. Reading it will give you everything there is to know about Volcano. | ||
- Creating a blog? Try out the official [Blog](https://github.com/sebastianks/volcano-blog-template) template and start blogging right away. | ||
- Need help with anything? Feel free to reach out [on Discord](https://discord.gg/pujumPht). |
Oops, something went wrong.