diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..dae4960
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,4 @@
+RewriteEngine on
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ ./router.php [L,QSA]
\ No newline at end of file
diff --git a/admin/admin.css b/admin/admin.css
new file mode 100644
index 0000000..e69de29
diff --git a/admin/admin.js b/admin/admin.js
new file mode 100644
index 0000000..e69de29
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..e69de29
diff --git a/admin/modules/default/exampleModule.php b/admin/modules/default/exampleModule.php
new file mode 100644
index 0000000..2a33568
--- /dev/null
+++ b/admin/modules/default/exampleModule.php
@@ -0,0 +1,3 @@
+function testModule($modulesVars, $elementVars) {
+ return new DO
+}
\ No newline at end of file
diff --git a/admin/modules/default/module.php b/admin/modules/default/module.php
new file mode 100644
index 0000000..e69de29
diff --git a/admin/settings/admin.json b/admin/settings/admin.json
new file mode 100644
index 0000000..ce6b10a
--- /dev/null
+++ b/admin/settings/admin.json
@@ -0,0 +1,4 @@
+{
+ "theme": "default",
+ "modules": ["default"]
+}
\ No newline at end of file
diff --git a/admin/settings/scripts.json b/admin/settings/scripts.json
new file mode 100644
index 0000000..e69de29
diff --git a/admin/settings/styles.json b/admin/settings/styles.json
new file mode 100644
index 0000000..e69de29
diff --git a/admin/settings/templates.json b/admin/settings/templates.json
new file mode 100644
index 0000000..e75d0bf
--- /dev/null
+++ b/admin/settings/templates.json
@@ -0,0 +1,6 @@
+{
+ "default": {
+ "URI": "pouet/pouet.php",
+ "static": true
+ }
+}
\ No newline at end of file
diff --git a/admin/themes/default/templates/page.php b/admin/themes/default/templates/page.php
new file mode 100644
index 0000000..15c5adc
--- /dev/null
+++ b/admin/themes/default/templates/page.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/admin/themes/default/theme.php b/admin/themes/default/theme.php
new file mode 100644
index 0000000..e69de29
diff --git a/pages/index.json b/pages/index.json
new file mode 100644
index 0000000..de23d3f
--- /dev/null
+++ b/pages/index.json
@@ -0,0 +1,9 @@
+{
+ "title": "Home",
+ "template": "page",
+ "access": "public",
+ "content": "
hello world
",
+ "modules": {
+ "?": "?"
+ }
+}
\ No newline at end of file
diff --git a/pages/pokemon.json b/pages/pokemon.json
new file mode 100644
index 0000000..b966688
--- /dev/null
+++ b/pages/pokemon.json
@@ -0,0 +1,3 @@
+{
+ "title":"test"
+}
\ No newline at end of file
diff --git a/public.php b/public.php
new file mode 100644
index 0000000..f53ae0b
--- /dev/null
+++ b/public.php
@@ -0,0 +1,21 @@
+
\ No newline at end of file
diff --git a/readme.md b/readme.md
index 049238e..d9416e2 100644
--- a/readme.md
+++ b/readme.md
@@ -8,100 +8,230 @@ WIP
see [changelog.md](./changelog.md)
+## Themes
+
+### Templates
+
+themes works via "templates".
+
+first a template named "page" is a must, your template can be static or not (static templates will be updated on document update while not static the templateFile will always be used)
+
+```php
+website->addTemplate("Template Name", "templateURI/from/root/page.php", "functionName", true);
+```
+- `"Template Name"` is the shown name
+- `"templateURI"` is the file URI
+- `"functionName"` is the function used
+- `true` is to says to the website if this template is static or not (default to `false`)
+
+if cache is disabled globally static or not static pages will be updated at every load
+
+example: a template named `Blog Page` can be static while a `Blog List` shouldn't be static to load newly added blog pages
+
+```php
+website->addTemplate("Blog Page", "templates/blog.php", "page", true);
+website->addTemplate("Blog List", "templates/blog.php", "list", false);
+```
+
+### styles & scripts
+
+themes must declare each scripts & styles so they can be cached when needed
+
+```php
+website->addNewStyle("styleURI/from/style/root/page.css", "styleName", ["styleDependency"]);
+website->addNewScript("scriptURI/from/script/root/page.js", "scriptName", ["scriptdependency", "JQuery"]);
+```
+
+- `"styleURI"`/`"scriptURI"` is the link to the file
+- [OPTIONAL] `"styleName"`/`"scriptName"` is the name of the style/script to be used by sub-dependencies
+- [OPTIONAL] `["styleDependency"]`/`["scriptDependency", "JQuery"]` are used to load theses scripts after the followed dependencies
+
+### Options
+
+Options are declarated in the same file than before
+and will be usable in the templates files
+
+updating an option will update the static files
+
+```php
+$optionMenu = website->addOptionsMenu("Menu Name");
+```
+here we create a new option menu that will be located in the admin sidebar `theme -> Options` within the tabs
+
+- `"Menu Name"` is the shown name
+
+```php
+$optionMenu->addTextOption("Option Name", "variableName", "defaultValue", {
+ "min": 1,
+ "max": 16,
+ "placeholder": "placeholder"
+});
+```
+
+## Modules
+
+modules will work like this in the `page.content` of the page `[moduleName variablesName="valueName"]`
+
+the module will then receive a variable named `$modVars` that will contain `$modVars->variableName` = `valueName` and will have to return a `String` Object
+
+To keep the document strict it's advised to use the php `DOMDocument` Object
+
## Files/Folders architecture
- index.php (is it really necessary ?)
- .htaccess (handle file redirection)
+- router.php (handle the first route part ( separating the loading process))
- uploads/
- cache/ (public cache (won't be seen by client via .htaccess redirection))
- - .htaccess (make sure clients can't access this folder)
- - scripts.js
- - styles.css
+ - .htaccess (make sure clients can't access this folder)
+ - scripts.js
+ - styles.css
- pages/ (NO `scripts.js` NOR `styles.css` NOR `admin` NOR `login` files must be in here)
- - .htaccess (make sure clients can't access this folder)
- - index.json (this index.json will be the root name "/")
- - slugname.json (path = "/slugname")
- - iamjson.json.json (path = "/iamjson.json" wand with a module/theme could just return json)
- - folderslug/
- - index.json (path = "/folderslug" if no index.json is given there will be a 404 error for "/folderslug" but not for the "/folderslug/pouet")
- - pouet.json (path = "/folderslug/pouet")
+ - .htaccess (make sure clients can't access this folder)
+ - index.json (this index.json will be the root name "/")
+ - slugname.json (path = "/slugname")
+ - iamjson.json.json (path = "/iamjson.json" wand with a module/theme could just return json)
+ - folderslug/
+ - index.json (path = "/folderslug" if no index.json is given there will be a 404 error for "/folderslug" but not for the "/folderslug/pouet")
+ - pouet.json (path = "/folderslug/pouet")
- admin/
- - .htaccess manage redirection for admin pages (pass throught a verify login script)
- - index.php
- - admin.js
- - admin.css
- - settings/ (settings files more infos [here](#config-files))
- - scripts.json (if cache is disabled these files will be used to get the styles & scripts)
- - styles.json (else these files are only used to create the caches files)
- - admin.json (admin settings (see admin.json section))
- - templates.json (simple name to redirect)
- - modules/
- - moduleName.json
- - themes/
- - themeName.json
- - admin.list (used to see what to launch on the admin side)
- - options.list (options for modules & themes to be used site-wide)
- - templates.list (store the template used on the website with a link to there .php file)
- - themes/ (when a new theme is loaded regenerate scripts.js & styles.css, an option will allow the use of direct files)
- - default/ (a default theme will be here)
- - theme.php
- - themeName/
- - theme.php (only launched on theme load, to generate cache files & admin options files)
- - public.php (launched everytime on website when page is launched (admins sections are excluded)
- - admin.php (launched everytime on admin/themename/** launch (with args like page))
- - templates/ (all folders included under are optional anc can be located somewhere else in the theme folder)
- - page.php (at least a template named "page" must exist to make the theme usable)
- - templateName.php (file launched everytime a page is loaded with the template selected)
- - css/
- - js/
- - modules/
- - default/ (a default module will be here)
- - module.php
- - moduleName/
- - module.php
- - public.php (same as theme)
+ - .htaccess manage redirection for admin pages (pass throught a verify login script)
+ - index.php
+ - admin.js
+ - admin.css
+ - settings/ (settings files more infos [here](#config-files))
+ - scripts.json (if cache is disabled these files will be used to get the styles & scripts)
+ - styles.json (else these files are only used to create the caches files)
+ - admin.json (admin settings (see admin.json section))
+ - templates.json (simple name to redirect)
+ - modules/
+ - moduleName/
+ - settings.json
+ - vars.json
+ - themes/
+ - themeName/
+ - settings.json
+ - vars.json
+ - admin.list (used to see what to launch on the admin side)
+ - options.list (options for modules & themes to be used site-wide)
+ - templates.list (store the template used on the website with a link to there .php file)
+ - themes/ (when a new theme is loaded regenerate scripts.js & styles.css, an option will allow the use of direct files)
+ - default/ (a default theme will be here)
+ - theme.php
+ - themeName/
+ - theme.php (only launched on theme load, to generate cache files & admin options files)
+ - public.php (launched everytime on website when page is launched (admins sections are excluded)
+ - admin.php (launched everytime on admin/themename/** launch (with args like page))
+ - templates/ (all folders included under are optional anc can be located somewhere else in the theme folder)
+ - page.php (at least a template named "page" must exist to make the theme usable)
+ - templateName.php (file launched everytime a page is loaded with the template selected)
+ - css/
+ - js/
+ - modules/
+ - default/ (a default module will be here)
+ - module.php
+ - moduleName/
+ - module.php
+ - public.php (same as theme)
## Configs files
+### page.json (in `pages` folder)
+```json
+{
+ "title": "pageTitle",
+ "template": "templateName",
+ "access": "typeOfAccess (public: everyone has access to the page, limited:only logged in users has access to the page, private: only the author & admins has access to the page)",
+ "author": "Aviortheking",
+ "content": "hello world
"
+}
+```
+
### scripts.json & styles.json
```json
{
- [
- "path/to/script"
- ]
+ [
+ "path/to/script"
+ ]
}
```
### admin.list
```json
{
- "themeUsed": "themeName",
- "modulesUsed": [
- "moduleName",
- "etc"
- ]
+ "themeUsed": "themeName",
+ "modulesUsed": [
+ "moduleName",
+ "etc"
+ ]
}
```
-### moduleName.json & themeName.json
+### vars.json
```json
{
- "variable1": "value1",
- "list1": [
- "pouet1",
- "etc"
- ]
- "variableSet1": {
- "subVariable1": "value2"
- }
+ "variable1": "value1",
+ "list1": [
+ "pouet1",
+ "etc"
+ ],
+ "variableSet1": {
+ "subVariable1": "value2"
+ }
+}
+```
+### moduleName.json & themeName.json
+*values for the options are located in the `vars.json` files*
+```json
+{
+ [
+ {
+ "title": "Menu Title",
+ "slug": "menu-title",
+ "options": {
+ "textOption": {
+ "type": "text",
+ "name": "Option Name",
+ },
+ "radioOption": {
+ "type": "radio",
+ "name": "Radio Option",
+ "values": [
+ "value1",
+ "value2",
+ "value3"
+ ],
+ },
+ "selectOption": {
+ "type": "select",
+ "name": "Select",
+ "value": [
+ "value1",
+ "value2",
+ "value3",
+ "etc"
+ ]
+ }
+ }
+ },
+ {
+ "title": "etc"
+ }
+ ]
}
```
### templates.list
*voir si il y auras tout les themes ou seulement le theme actif*
+
+if static is true then static webpage will be generated
```json
{
- "templateName": templates/templateName.php
+ "templateName": {
+ "URI": "templates/templateName.php",
+ "function": "functionName",
+ "static": false
+ }
}
```
\ No newline at end of file
diff --git a/router.php b/router.php
new file mode 100644
index 0000000..7ac467e
--- /dev/null
+++ b/router.php
@@ -0,0 +1,68 @@
+title);
+} else echo "404";
+/*
+
+verify if the page to load exist
+ if page is login/admin then continue;
+ elif the page is a file in /pages/pagename.json then continue
+ else return 404 error
+
+verify if user is logged in
+ if the user is logged in & the page is login return to /admin
+ elif the user is not logged in & the page is admin return to /login
+ else start the process to load the page
+
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function endsWith($haystack, $needle) {
+ $length = strlen($needle);
+ if ($length == 0) {
+ return true;
+ }
+
+ return (substr($haystack, -$length) === $needle);
+}
+
+?>
\ No newline at end of file
diff --git a/test.php b/test.php
new file mode 100644
index 0000000..bfa79ad
--- /dev/null
+++ b/test.php
@@ -0,0 +1,31 @@
+pouet