Skip to content

Commit

Permalink
Back to oui_flat (@gocom is back!)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGraph committed Mar 14, 2017
1 parent 0ce3457 commit c457489
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 208 deletions.
36 changes: 0 additions & 36 deletions CONTRIBUTING.textile

This file was deleted.

34 changes: 19 additions & 15 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. rah_flat
h1. oui_flat

"Download":https://github.com/NicolasGraph/rah_flat/releases | "Donate to the original author":http://rahforum.biz/donate/rah_flat
"Download":https://github.com/NicolasGraph/oui_flat/releases

This plugin makes your "Textpattern CMS":http://www.textpattern.com database more flat, manageable and editable. Edit templates, forms, pages, preferences, variables and sections as flat files. Use any editor, work in teams and store your website's source under your favorite "version control system":http://en.wikipedia.org/wiki/Revision_control.

Expand All @@ -24,7 +24,7 @@ h2. Table of contents

h2(#requirements). Plugin requirements

rah_flat’s minimum requirements:
oui_flat’s minimum requirements:

* Textpattern 4.5+

Expand All @@ -39,7 +39,7 @@ h2(#prefs). Preferences / options
* *Security key for the public callback* - Security key for the public callback hook URL. Importing is done when the URL is accessed. The URL follows the format of:
* *Production status for the systematic upload* - The site production status for which you want to activate the systematic templates upload (see "Basics":#basics).

bc. http://example.com/?rah_flat_key={yourKey}
bc. http://example.com/?oui_flat_key={yourKey}

Where @http://example.com/@ is your site's URL, and @{yourKey}@ is the security key you specified.

Expand All @@ -52,7 +52,7 @@ Your flat files are imported to the database:

1. Variables are imported only once to avoid the override of user strings. To update them, remove or rename .json files and refresh.

If you want to exclude a certain content type from importing, just don't create a directory for it. No directory, and rah_flat will leave the database alone when it comes to that content type.
If you want to exclude a certain content type from importing, just don't create a directory for it. No directory, and oui_flat will leave the database alone when it comes to that content type.

h3. About variables

Expand Down Expand Up @@ -135,7 +135,7 @@ Here is an example of content for a @menu_sections.json@ file.
bc.. {
"value": "articles, about, contact",
"type": "PREF_HIDDEN",
"event": "rah_flat_var",
"event": "oui_flat_var",
"html": "text_input",
"position": "10",
"is_private": true
Expand All @@ -145,20 +145,20 @@ p. where each data is optional and the default values are the following:

* @"value": "…"@ - _default: '' (empty)_ - The default value of the preference.
* @"type": "…"@ - _default: PREF_PLUGIN (for Txp 4.6, else PREF_ADVANCED)_ - To hide a pref in the _Preferences_ tab, use _PREF_HIDDEN_, you should probably not use _PREF_CORE_.
* "event": "…" - _default: 'rah_flat_var'_ - The prefs group name where you want to display your custom pref.
* "event": "…" - _default: 'oui_flat_var'_ - The prefs group name where you want to display your custom pref.
* @"html": "…"@ - _default: 'text_input'_ - To display radio buttons, use _onoffradio_ or _yesnoradio_.
* @"position": "…"@ - _default: 0_ - Use position to sort your prefs.
* @"is_private": "…"@ - _default: false_ - If _true_, the pref will be user related.

p. While you can call your custom preference as a Txp variable like so: @<txp:variable name="menu_sections" />@; they will be prefixed with @rah_flat_var_@ under the preferences tab and you will need to use the textpack as below to add user friendly titles.
p. While you can call your custom preference as a Txp variable like so: @<txp:variable name="menu_sections" />@; they will be prefixed with @oui_flat_var_@ under the preferences tab and you will need to use the textpack as below to add user friendly titles.

h3(#textpacks). Textpacks

Here is an example of content for a @en-gb.json@ file.

bc.. {
"admin": {
"rah_flat_var_menu_sections": "Sections used in the menu"
"oui_flat_var_menu_sections": "Sections used in the menu"
},
"common": {
},
Expand All @@ -172,7 +172,7 @@ p. Text strings are only updated if they already exist, otherwise, they can be i

h2(#author). Author

"Jukka Svahn":http://rahforum.biz/, forked by "Nicolas Morand":https://github.com/ from v0.3.0.
"Nicolas Morand":https://github.com/, from "rah_flat":https://github.com/gocom/rah_flat by "Jukka Svahn":http://rahforum.biz/.

h2(#licence). Licence

Expand All @@ -182,16 +182,20 @@ h2(#Changelog). Changelog

* To do: Fix the _Options_ link.

h3. Version 0.5.0- 2016/08/26
h3. Version 0.6.0 - 2017/03/14

* Changed: Back to @oui_@ plugin author prefix.

h3. Version 0.5.0 (rah_flat) - 2016/08/26

* Changed: Forms are stored by types in subfolders and don't need prefixes anymore.
* Added: Custom form types are changed to 'misc' when the plugin is disable to avoid an error in the Forms tab.
* Changed: Preferences update affects values only.
* Added: Prefs are hidden in the admin if set via flat files and get back to visible when the plugin is disabled.
* Added: Custom prefs (in the variables folder) accept more paramters in .json files.
* Changed: Custom prefs (in the variables folder) now have a rah_flat_var_ prefix added to their name.
* Changed: Custom prefs (in the variables folder) now have a oui_flat_var_ prefix added to their name.

h3. Version 0.4.0 (oui_flat) - 2015/11/29
h3. Version 0.4.0 - 2015/11/29

* Changed: Forked by Nicolas Morand.
* Added: Custom preferences can be created and use as Txp variables.
Expand All @@ -200,12 +204,12 @@ h3. Version 0.4.0 (oui_flat) - 2015/11/29
h3. Version 0.3.0 - 2014/03/28

* Added: Drop access to a admin-side panel only if the specific content-type is active and has a directory set up.
* Added: Invokable @rah_flat.import@ callback event.
* Added: Invokable @oui_flat.import@ callback event.
* Added: Sections and preferences get their names from the filename.
* Added: Preferences are always just updated, no strands are created.
* Added: Preference fields that are not specified in a file are kept as-is in the database.
* Added: French translation by "Patrick Lefevre":https://github.com/cara-tm.
* Changed: Renamed confusing @rah_flat_Import_Template@ interface to @rah_flat_Import_ImportInterface@.
* Changed: Renamed confusing @oui_flat_Import_Template@ interface to @oui_flat_Import_ImportInterface@.

h3. Version 0.2.0 - 2014/03/19

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "rah/rah_flat",
"name": "nicolasgraph/oui_flat",
"description": "Textpattern CMS templates as flat files",
"keywords": ["textpattern", "plugin", "flat", "template"],
"homepage": "https://github.com/gocom/rah_flat",
"homepage": "https://github.com/nicolasgraph/oui_flat",
"license": "GPL-2.0",
"type": "textpattern-plugin",
"authors": [
{
"name": "Jukka Svahn",
"homepage": "http://rahforum.biz",
"name": "Nicolas Morand, Jukka Svahn",
"homepage": "https://github.com/nicolasgraph",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/gocom/rah_flat/issues",
"source": "https://github.com/gocom/rah_flat"
"issues": "https://github.com/nicolasgraph/oui_flat/issues",
"source": "https://github.com/nicolasgraph/oui_flat"
},
"require": {
"php": ">=5.2.0",
"textpattern/lock": ">=4.4.1",
"textpattern/lock": ">=4.6",
"textpattern/installer": "*"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name" : "rah_flat",
"name" : "oui_flat",
"description" : "Edit Textpattern's database prefs, contents and page templates as flat files",
"version" : "0.5.0",
"version" : "0.6.0",
"type" : 1,
"author" : "Jukka Svahn (forked by Nicolas Morand)",
"author" : "Nicolas Morand from Jukka Svahn's rah_flat",
"author_uri" : "http://github.com/NicolasGraph",
"order" : 5,
"flags" : 3,
Expand Down
76 changes: 38 additions & 38 deletions src/Rah/Flat.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php

/*
* rah_flat - Flat templates for Textpattern CMS
* https://github.com/gocom/rah_flat
* oui_flat - Flat templates for Textpattern CMS
* https://github.com/gocom/oui_flat
*
* Copyright (C) 2015 Jukka Svahn
*
* This file is part of rah_flat.
* This file is part of oui_flat.
*
* rah_flat is free software; you can redistribute it and/or
* oui_flat is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* rah_flat is distributed in the hope that it will be useful,
* oui_flat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rah_flat. If not, see <http://www.gnu.org/licenses/>.
* along with oui_flat. If not, see <http://www.gnu.org/licenses/>.
*/

/**
Expand All @@ -27,7 +27,7 @@
* @internal
*/

class Rah_Flat
class Oui_Flat
{
protected $deleting = false;

Expand All @@ -38,35 +38,35 @@ class Rah_Flat
public function __construct()
{
if (@txpinterface == 'admin') {
add_privs('prefs.rah_flat', '1');
add_privs('prefs.rah_flat_var', '1');
register_callback(array($this, 'options'), 'plugin_prefs.rah_flat', null, 1);
register_callback(array($this, 'install'), 'plugin_lifecycle.rah_flat', 'installed');
register_callback(array($this, 'disable'), 'plugin_lifecycle.rah_flat', 'disabled');
register_callback(array($this, 'uninstall'), 'plugin_lifecycle.rah_flat', 'deleted');
add_privs('prefs.oui_flat', '1');
add_privs('prefs.oui_flat_var', '1');
register_callback(array($this, 'options'), 'plugin_prefs.oui_flat', null, 1);
register_callback(array($this, 'install'), 'plugin_lifecycle.oui_flat', 'installed');
register_callback(array($this, 'disable'), 'plugin_lifecycle.oui_flat', 'disabled');
register_callback(array($this, 'uninstall'), 'plugin_lifecycle.oui_flat', 'deleted');
}

if (get_pref('rah_flat_path')) {
new rah_flat_Import_Variables('variables');
new rah_flat_Import_Prefs('prefs');
new rah_flat_Import_Sections('sections');
new rah_flat_Import_Pages('pages');
new rah_flat_Import_Styles('styles');
new rah_flat_Import_Textpacks('textpacks');
$forms = txpath . '/' . get_pref('rah_flat_path') . '/forms';
if (get_pref('oui_flat_path')) {
new oui_flat_Import_Variables('variables');
new oui_flat_Import_Prefs('prefs');
new oui_flat_Import_Sections('sections');
new oui_flat_Import_Pages('pages');
new oui_flat_Import_Styles('styles');
new oui_flat_Import_Textpacks('textpacks');
$forms = txpath . '/' . get_pref('oui_flat_path') . '/forms';
if (file_exists($forms) && is_dir($forms) && is_readable($forms)) {
foreach (array_diff(scandir($forms), array('.', '..')) as $formType) {
if (is_dir($forms . '/' . $formType)) {
new rah_flat_Import_Forms('forms/'.$formType);
new oui_flat_Import_Forms('forms/'.$formType);
}
}
}

register_callback(array($this, 'injectVars'), 'pretext_end');
register_callback(array($this, 'endpoint'), 'textpattern');
register_callback(array($this, 'initWrite'), 'rah_flat.import');
register_callback(array($this, 'initWrite'), 'oui_flat.import');

if (in_list(get_pref('production_status'), get_pref('rah_flat_upload_levels'))) {
if (in_list(get_pref('production_status'), get_pref('oui_flat_upload_levels'))) {
register_callback(array($this, 'callbackHandler'), 'textpattern');
register_callback(array($this, 'callbackHandler'), 'admin_side', 'body_end');
}
Expand All @@ -83,7 +83,7 @@ public function injectVars()

$prefset = safe_rows('name, val', 'txp_prefs', "name like 'rah\_flat\_var\_%'");
foreach ($prefset as $pref) {
$variable[substr($pref['name'], strlen('rah_flat_var_'))] = $pref['val'];
$variable[substr($pref['name'], strlen('oui_flat_var_'))] = $pref['val'];
}
}

Expand All @@ -98,17 +98,17 @@ public function install()
$position = 250;

$options = array(
'rah_flat_path' => array('text_input', ''),
'rah_flat_key' => array('text_input', md5(uniqid(mt_rand(), true))),
'rah_flat_upload_levels' => array('upload_levels', 'debug, testing'),
'oui_flat_path' => array('text_input', ''),
'oui_flat_key' => array('text_input', md5(uniqid(mt_rand(), true))),
'oui_flat_upload_levels' => array('upload_levels', 'debug, testing'),
);

foreach ($options as $name => $val) {
if (get_pref($name, false) === false) {
set_pref(
$name,
$val[1],
'rah_flat',
'oui_flat',
defined('PREF_PLUGIN') ? PREF_PLUGIN : PREF_ADVANCED,
$val[0],
$position
Expand All @@ -126,7 +126,7 @@ public function install()
public function options()
{
$url = defined('PREF_PLUGIN')
? '?event=prefs#prefs_group_rah_flat'
? '?event=prefs#prefs_group_oui_flat'
: '?event=prefs&step=advanced_prefs';
header('Location: ' . $url);
}
Expand Down Expand Up @@ -159,8 +159,8 @@ public function disable()
public function uninstall()
{
safe_delete('txp_prefs', "name like 'rah\_flat\_%'");
safe_delete('txp_lang', "owner = 'rah_flat'");
safe_delete('txp_lang', "owner = 'rah_flat_lang'");
safe_delete('txp_lang', "owner = 'oui_flat'");
safe_delete('txp_lang', "owner = 'oui_flat_lang'");
$this->deleting = true;
}

Expand All @@ -170,7 +170,7 @@ public function uninstall()

public function initWrite()
{
callback_event('rah_flat.import_to_database');
callback_event('oui_flat.import_to_database');
}

/**
Expand All @@ -181,7 +181,7 @@ public function callbackHandler()
{
if (!$this->deleting) {
try {
callback_event('rah_flat.import');
callback_event('oui_flat.import');
} catch (Exception $e) {
trigger_error($e->getMessage());
}
Expand All @@ -194,14 +194,14 @@ public function callbackHandler()

public function endpoint()
{
if (!get_pref('rah_flat_key') || get_pref('rah_flat_key') !== gps('rah_flat_key')) {
if (!get_pref('oui_flat_key') || get_pref('oui_flat_key') !== gps('oui_flat_key')) {
return;
}

header('Content-Type: application/json; charset=utf-8');

try {
callback_event('rah_flat.import');
callback_event('oui_flat.import');
} catch (Exception $e) {
txp_status_header('500 Internal Server Error');

Expand All @@ -221,7 +221,7 @@ public function endpoint()

/**
* Set upload_levels pref
* To do: move in rah_flat class?
* To do: move in oui_flat class?
*/
function upload_levels($name, $val)
{
Expand All @@ -234,4 +234,4 @@ function upload_levels($name, $val)
return selectInput($name, $vals, $val, true, '', $name);
}

new rah_flat();
new oui_flat();
Loading

0 comments on commit c457489

Please sign in to comment.