1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Stub of Conf class; schema tweaks

This commit is contained in:
J. King 2016-09-27 09:00:02 -04:00
parent c3bc913240
commit 4639dd1c46
4 changed files with 82 additions and 11 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
#dependencies
inc/simplepie/*
vendor/simplepie/*
#temp files
cache/*

16
bootstrap.php Normal file
View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
const BASE = __DIR__.DIRECTORY_SEPARATOR;
spl_autoload_register(function ($class) {
if($class=="SimplePie") return;
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class);
$file = BASE."vendor".DIRECTORY_SEPARATOR.$file.".php";
if (file_exists($file)) {
require_once $file;
}
});
$conf = new Conf();

View file

@ -1,7 +1,7 @@
begin;
-- users
create table chibi_users(
create table newssync_users(
id TEXT primary key not null, -- user id
password TEXT, -- password, salted and hashed; if using external authentication this would be blank
name TEXT, -- display name
@ -11,7 +11,7 @@ create table chibi_users(
);
-- TT-RSS categories and ownCloud folders
create table chibi_categories(
create table newssync_categories(
id integer primary key not null, -- sequence number
owner TEXT references users(id) on delete cascade on update cascade, -- owner of category
parent integer, -- parent category id
@ -22,7 +22,7 @@ create table chibi_categories(
);
-- newsfeeds, deduplicated
create table chibi_feeds(
create table newssync_feeds(
id integer primary key not null, -- sequence number
url TEXT not null, -- URL of feed
title TEXT, -- default title of feed
@ -38,7 +38,7 @@ create table chibi_feeds(
);
-- users' subscriptions to newsfeeds, with settings
create table chibi_subscriptions(
create table newssync_subscriptions(
id integer primary key not null, -- sequence number
owner TEXT references users(id) on delete cascade on update cascade, -- owner of subscription
feed integer references feeds(id) on delete cascade, -- feed for the subscription
@ -52,7 +52,7 @@ create table chibi_subscriptions(
);
-- entries in newsfeeds
create table chibi_articles(
create table newssync_articles(
id integer primary key not null, -- sequence number
feed integer references feeds(id) on delete cascade, -- feed for the subscription
url TEXT not null, -- URL of article
@ -70,7 +70,7 @@ create table chibi_articles(
);
-- users' actions on newsfeed entries
create table chibi_subscription_articles(
create table newssync_subscription_articles(
id integer primary key not null,
article integer references articles(id) on delete cascade,
read boolean not null default 0,
@ -79,24 +79,31 @@ create table chibi_subscription_articles(
);
-- enclosures associated with articles
create table chibi_enclosures(
create table newssync_enclosures(
article integer references articles(id) on delete cascade,
url TEXT,
type varchar(255)
);
-- author labels ("categories" in RSS/Atom parlance) associated with newsfeed entries
create table chibi_tags(
create table newssync_tags(
article integer references articles(id) on delete cascade,
name TEXT
);
-- user labels associated with newsfeed entries
create table chibi_labels(
create table newssync_labels(
sub_article integer references subscription_articles(id) on delete cascade,
owner TEXT references users(id) on delete cascade on update cascade,
name TEXT
);
create index chibi_label_names on chibi_labels(name);
create index newssync_label_names on newssync_labels(name);
create table newssync_settings(
key varchar(255) primary key not null,
value varchar(255),
type varchar(255) not null
);
insert into newssync_settings values('schema_version',0,'int');
commit;

48
vendor/JKingWeb/NewsSync/Conf.php vendored Normal file
View file

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
class Conf {
public $dbType = "SQLite3";
public $dbSQLite3PDO = false;
public $dbSQLite3File = BASE."newssync.db";
public $dbPostgreSQLPDO = false;
public $dbPostgreSQLHost = "localhost";
public $dbPostgreSQLUser = "newssync";
public $dbPostgreSQLPass = "";
public $dbPostgreSQLPort = 5432;
public $dbPostgreSQLDb = "newssync";
public $dbPostgreSQLSchema = "";
public $dbMySQLPDO = false;
public $dbMySQLHost = "localhost";
public $dbMySQLUser = "newssync";
public $dbMySQLPass = "";
public $dbMySQLPort = 3306;
public $dbMySQLDb = "newssync";
public $simplepieCache = BASE.".cache";
function __construct(string $import_file = "") {
if($import_file != "") $this->import($import_file);
}
function import(string $file): bool {
$json = @file_get_contents($file);
if($json===false) return false;
$json = json_decode($json, true);
if(!is_array(json)) return false;
foreach($json as $key => $value) {
$this->$$key = $value;
}
return true;
}
function export(string $file = ""): string {
return json_encode($this, JSON_PRETTY_PRINT);
}
function __toString(): string {
return $this->export();
}
}