mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 10:57:01 +00:00
added setting dev code
This commit is contained in:
parent
154464bab5
commit
3c53958bf0
5 changed files with 327 additions and 0 deletions
54
_wip_todo/settings/config.ini
Normal file
54
_wip_todo/settings/config.ini
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
; timeline / twtxt-php
|
||||
; Copy this file into a config.ini file and edit the following settings
|
||||
|
||||
[main_settings]
|
||||
; Enable to display PHP errors
|
||||
; true or false
|
||||
debug_mode = false
|
||||
|
||||
; Time to wait before reloading URLs
|
||||
cache_refresh_time = 15
|
||||
|
||||
; Max execution time to avoid running to the infinite
|
||||
max_execution_time = 300
|
||||
|
||||
; Title of your website
|
||||
; used to navigate to the root of your domain
|
||||
site_title = "Timeline"
|
||||
|
||||
; Check that your current user has permissions for this file
|
||||
; Check also the user owner is correct, www-data for instance
|
||||
; TODO: Implement a way to know we have access to this file
|
||||
; since there are many different conditions for not having
|
||||
; access.
|
||||
txt_file_path = "twtxt.txt"
|
||||
|
||||
; Full URL for your public twtxt.txt file
|
||||
public_txt_url = "https://example.com/timeline/twtxt.txt"
|
||||
public_avatar = "https://example.com/timeline/avatar.png"
|
||||
public_nick = "Timeline"
|
||||
|
||||
; Check available timezones here:
|
||||
; https://www.php.net/manual/en/timezones.php
|
||||
timezone = "Europe/Copenhagen"
|
||||
|
||||
twts_per_page = 50
|
||||
|
||||
; E-mail for comments
|
||||
email = ""
|
||||
|
||||
; Webmentions log file
|
||||
webmentions_txt_path = "./mentions.txt"
|
||||
public_webmentions = "https://example.com/timeline/mentions.txt"
|
||||
|
||||
[security]
|
||||
; Generate it with the TOTP module
|
||||
totp_digits = 10
|
||||
totp_secret = "1234567890"
|
||||
|
||||
; It's recommended that your site is hosted on HTTPS
|
||||
; In case it's in HTTP (not secure), set this to false
|
||||
secure_cookies = true
|
||||
|
||||
; Simple password for unnamed user
|
||||
password = ""
|
||||
27
_wip_todo/settings/index.php
Normal file
27
_wip_todo/settings/index.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
// https://www.w3schools.io/ini-read-write-php/
|
||||
|
||||
$config = parse_ini_file("config.ini");
|
||||
|
||||
print_r("<pre>");
|
||||
print_r($config);
|
||||
print_r("</pre>");
|
||||
|
||||
if ($config !== false) {
|
||||
|
||||
echo '<h1>Settings for Timeline</h1><form>';
|
||||
|
||||
// TODO: Hardcode each for field and set types
|
||||
foreach ($config as $key => $value) {
|
||||
echo '<p><label for="'.$key.'">'.$key.':</label><br>';
|
||||
echo '<input type="text" id="'.$key.'" name="'.$key.'" value="'.$value.'"></p>';
|
||||
}
|
||||
|
||||
echo '<input type="submit" value="Save"></form>';
|
||||
|
||||
} else {
|
||||
echo 'Read INI file Failed.';
|
||||
}
|
||||
|
||||
|
||||
150
_wip_todo/settings/settings.php
Normal file
150
_wip_todo/settings/settings.php
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
|
||||
<style type="text/css">
|
||||
input[type="text"] {
|
||||
width: 100%;}
|
||||
</style>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// https://www.w3schools.io/ini-read-write-php/
|
||||
|
||||
$config = parse_ini_file("config.ini");
|
||||
|
||||
$configWithSections = parse_ini_file("config.ini",true,INI_SCANNER_RAW);
|
||||
|
||||
if ($config !== false) {
|
||||
|
||||
?>
|
||||
|
||||
<h1>Settings for Timeline</h1>
|
||||
|
||||
<form>
|
||||
|
||||
<fieldset>
|
||||
<legend>Advanced</legend>
|
||||
|
||||
<p>
|
||||
<label for="debug_mode">Enable to display PHP errors</label>
|
||||
<input type="text" id="debug_mode" name="debug_mode" value="">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="cache_refresh_time">Time to wait before reloading URLs</label>
|
||||
<input type="text" id="cache_refresh_time" name="cache_refresh_time" value="15">
|
||||
</p>
|
||||
<p>
|
||||
<label for="max_execution_time">Max execution time to avoid running to the infinite</label>
|
||||
<input type="text" id="max_execution_time" name="max_execution_time" value="300">
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Metadata</legend>
|
||||
|
||||
<p>
|
||||
<label for="site_title">Title of your website</label>
|
||||
<input type="text" id="site_title" name="site_title" value="Timeline">
|
||||
</p>
|
||||
<p>
|
||||
<label for="txt_file_path">Local path to your twtxt.txt</label>
|
||||
<input type="text" id="txt_file_path" name="txt_file_path" value="twtxt.txt">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<em>TODO: The following should be pulled from your twtxt.txt</em><br>
|
||||
<em>TODO: or should it be saved totwtxt.txt?</em>
|
||||
</p>
|
||||
<p>
|
||||
<label for="public_txt_url">Public URL for your twtxt.txt</label>
|
||||
<input type="text" id="public_txt_url" name="public_txt_url" value="https://example.com/timeline/twtxt.txt">
|
||||
</p>
|
||||
<p>
|
||||
<label for="public_avatar">Public URL for your avatar image</label>
|
||||
<input type="text" id="public_avatar" name="public_avatar" value="https://example.com/timeline/avatar.png">
|
||||
</p>
|
||||
<p>
|
||||
<label for="public_nick">Your nickname</label>
|
||||
<input type="text" id="public_nick" name="public_nick" value="yarner">
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<fieldset>
|
||||
<legend>Interface</legend>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
<label for="timezone">Timezone</label>
|
||||
<!-- <input type="text" id="timezone" name="timezone" value="Europe/Copenhagen"> -->
|
||||
<?php include "timezone.php"; ?>
|
||||
</p>
|
||||
<p>
|
||||
<label for="twts_per_page">Posts per page</label>
|
||||
<input type="text" id="twts_per_page" name="twts_per_page" value="50">
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Integrations</legend>
|
||||
<p>
|
||||
<label for="webmentions_txt_path">Webmentions - Local path to txt</label>
|
||||
<input type="text" id="webmentions_txt_path" name="webmentions_txt_path" value="./mentions.txt">
|
||||
</p>
|
||||
<p>
|
||||
<label for="public_webmentions">Webmentions - URL to txt</label>
|
||||
<input type="text" id="public_webmentions" name="public_webmentions" value="https://example.com/timeline/mentions.txt">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="email">E-mail for "Reply via email" feature (leave blank to deactive)</label>
|
||||
<input type="text" id="email" name="email" value="">
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Login</legend>
|
||||
|
||||
<p>
|
||||
<label for="totp_digits">TOTP - Number of digits</label>
|
||||
<input type="text" id="totp_digits" name="totp_digits" value="10">
|
||||
</p>
|
||||
<p>
|
||||
<label for="totp_secret">TOTP - Secret:</label>
|
||||
<input type="text" id="totp_secret" name="totp_secret" value="1234567890">
|
||||
</p>
|
||||
<p>
|
||||
<label for="secure_cookies">Secure Cookies</label>
|
||||
<!-- <input type="text" id="secure_cookies" name="secure_cookies" value="1"> -->
|
||||
<input type="checkbox" id="secure_cookies" name="secure_cookies" value="1">
|
||||
It's recommended that your site is hosted on HTTPS.
|
||||
In case it's in HTTP (not secure), turn this off
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" value="">
|
||||
</p>
|
||||
<input type="submit" value="Save">
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<?php }
|
||||
|
||||
|
||||
print_r("<pre>");
|
||||
print_r($config);
|
||||
print_r($configWithSections);
|
||||
print_r("</pre>");
|
||||
|
||||
|
||||
|
||||
?>
|
||||
47
_wip_todo/settings/timezone.php
Normal file
47
_wip_todo/settings/timezone.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
// from: https://gist.github.com/Xeoncross/1204255
|
||||
|
||||
$regions = array(
|
||||
'Africa' => DateTimeZone::AFRICA,
|
||||
'America' => DateTimeZone::AMERICA,
|
||||
'Antarctica' => DateTimeZone::ANTARCTICA,
|
||||
'Aisa' => DateTimeZone::ASIA,
|
||||
'Atlantic' => DateTimeZone::ATLANTIC,
|
||||
'Europe' => DateTimeZone::EUROPE,
|
||||
'Indian' => DateTimeZone::INDIAN,
|
||||
'Pacific' => DateTimeZone::PACIFIC
|
||||
);
|
||||
|
||||
$timezones = array();
|
||||
foreach ($regions as $name => $mask)
|
||||
{
|
||||
$zones = DateTimeZone::listIdentifiers($mask);
|
||||
foreach($zones as $timezone)
|
||||
{
|
||||
// Lets sample the time there right now
|
||||
//$time = new DateTime("Europe/London", new DateTimeZone($timezone));
|
||||
|
||||
// Us dumb Americans can't handle millitary time
|
||||
//$ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
|
||||
|
||||
// Remove region name and add a sample time
|
||||
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1); // . ' - ' . $time->format('H:i') . $ampm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// View
|
||||
|
||||
print '<label>Select Your Timezone</label><select id="timezone">';
|
||||
foreach($timezones as $region => $list)
|
||||
{
|
||||
print '<optgroup label="' . $region . '">' . "\n";
|
||||
foreach($list as $timezone => $name)
|
||||
{
|
||||
$name = str_replace('_', ' ', $name);
|
||||
print '<option name="' . $timezone . '">' . $name . '</option>' . "\n";
|
||||
}
|
||||
print '<optgroup>' . "\n";
|
||||
}
|
||||
print '</select>';
|
||||
49
_wip_todo/settings/timezone2.php
Normal file
49
_wip_todo/settings/timezone2.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
// Based on: https://davidhancock.co/2013/05/generating-a-list-of-timezones-with-php/
|
||||
|
||||
/**
|
||||
* Return an array of timezones
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function timezoneList()
|
||||
{
|
||||
$timezoneIdentifiers = DateTimeZone::listIdentifiers();
|
||||
$utcTime = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
$tempTimezones = array();
|
||||
foreach ($timezoneIdentifiers as $timezoneIdentifier) {
|
||||
$currentTimezone = new DateTimeZone($timezoneIdentifier);
|
||||
|
||||
$tempTimezones[] = array(
|
||||
'offset' => (int)$currentTimezone->getOffset($utcTime),
|
||||
'identifier' => $timezoneIdentifier
|
||||
);
|
||||
}
|
||||
|
||||
// Sort the array by offset,identifier ascending
|
||||
usort($tempTimezones, function($a, $b) {
|
||||
return ($a['offset'] == $b['offset'])
|
||||
? strcmp($a['identifier'], $b['identifier'])
|
||||
: $a['offset'] - $b['offset'];
|
||||
});
|
||||
|
||||
$timezoneList = array();
|
||||
foreach ($tempTimezones as $tz) {
|
||||
$sign = ($tz['offset'] > 0) ? '+' : '-';
|
||||
$offset = gmdate('H:i', abs($tz['offset']));
|
||||
$tz['identifier'] = str_replace('_', ' ', $tz['identifier']);
|
||||
$timezoneList[$tz['identifier']] = $tz['identifier'] . ' (UTC ' . $sign . $offset . ')';
|
||||
}
|
||||
|
||||
return $timezoneList;
|
||||
}
|
||||
|
||||
$timezoneList = timezoneList();
|
||||
echo '<select name="timezone">';
|
||||
foreach ($timezoneList as $value => $label) {
|
||||
echo '<option value="' . $value . '">' . $label . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
Loading…
Reference in a new issue