Merge pull request #633 from MrPetovan/task/4889-move-config-to-config

Move configuration to config/
This commit is contained in:
Michael Vogel 2018-07-18 11:04:38 +02:00 committed by GitHub
commit 3940618a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 607 additions and 223 deletions

View file

@ -3,16 +3,28 @@ Twitter Addon
Main authors Tobias Diekershoff, Michael Vogel and Hypolite Petovan.
This bi-directional connector addon allows each user to crosspost their Friendica public posts to Twitter, import their
Twitter timeline, interact with tweets from Friendica, and crosspost to Friendica their public tweets.
This bi-directional connector addon allows each user to crosspost their Friendica public posts to Twitter, import their Twitter timeline, interact with tweets from Friendica, and crosspost to Friendica their public tweets.
## Installation
To use this addon you have to register an [application](https://apps.twitter.com/) for your Friendica instance on Twitter.
Register your Friendica site as "Client" application with "Read & Write" access we do not need "Twitter as login".
Please leave the field "Callback URL" empty.
When you've registered the app you get the OAuth Consumer key and secret pair for your application/site.
After the registration please enter the values for "Consumer Key" and "Consumer Secret" in the [administration](admin/addons/twitter).
## Alternative configuration
Add your key pair to your global config/addon.ini.php.
[twitter]
consumerkey = your consumer_key here
consumersecret = your consumer_secret here
To activate the addon itself add it to the [system] addon setting.
After this, users can configure their Twitter account settings from "Settings -> Addon Settings".
## License
The _Twitter Connector_ is licensed under the [3-clause BSD license][2] see the LICENSE file in the addons directory.

View file

@ -0,0 +1,16 @@
<?php return <<<INI
; Warning: Don't change this file! It only holds the default config values for this addon.
; Instead overwrite these config values in config/addon.ini.php in your Friendica directory
[twitter]
; consumerkey (String)
; OAuth Consumer Key provided by Twitter on registering an app at https://twitter.com/apps
consumerkey =
; consumersecret (String)
; OAuth Consumer Secret provided by Twitter on registering an app at https://twitter.com/apps
consumersecret =
INI;
//Keep this line

View file

@ -48,12 +48,13 @@
* we do not need "Twitter as login". When you've registered the app you get the
* OAuth Consumer key and secret pair for your application/site.
*
* Add this key pair to your global .htconfig.php or use the admin panel.
* Add this key pair to your global config/addon.ini.php or use the admin panel.
*
* $a->config['twitter']['consumerkey'] = 'your consumer_key here';
* $a->config['twitter']['consumersecret'] = 'your consumer_secret here';
* [twitter]
* consumerkey = your consumer_key here
* consumersecret = your consumer_secret here
*
* To activate the addon itself add it to the $a->config['system']['addon']
* To activate the addon itself add it to the [system] addon
* setting. After this, your user can configure their Twitter account settings
* from "Settings -> Addon Settings".
*
@ -94,6 +95,7 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
function twitter_install()
{
// we need some hooks, for the configuration and for sending tweets
Addon::registerHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
Addon::registerHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
Addon::registerHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
Addon::registerHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
@ -110,6 +112,7 @@ function twitter_install()
function twitter_uninstall()
{
Addon::unregisterHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
Addon::unregisterHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
Addon::unregisterHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
Addon::unregisterHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
@ -128,6 +131,11 @@ function twitter_uninstall()
Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
}
function twitter_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/twitter.ini.php');
}
function twitter_check_item_notification(App $a, &$notification_data)
{
$own_id = PConfig::get($notification_data["uid"], 'twitter', 'own_id');

View file

@ -4,7 +4,7 @@ use Friendica\Core\Config;
function twitter_sync_run($argv, $argc)
{
global $a;
$a = Friendica\BaseObject::getApp();
require_once 'addon/twitter/twitter.php';