Skip to content

Commit

Permalink
add new apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Posselt committed May 13, 2017
1 parent 86c39a7 commit 53822bb
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 248 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ appstore:
rm -rf $(appstore_build_directory) $(appstore_artifact_directory)
mkdir -p $(appstore_build_directory) $(appstore_artifact_directory)
cp --parents -r \
"admin" \
"appinfo" \
"css" \
"img" \
Expand Down
23 changes: 0 additions & 23 deletions admin/admin.php

This file was deleted.

2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

require_once __DIR__ . '/../vendor/autoload.php';

(new Application)->registerConfig();
\OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\News\Hooks\User', 'deleteUser');
27 changes: 9 additions & 18 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Before you update to a new version, [check the changelog](https://github.com/nextcloud/news/blob/master/CHANGELOG.md) to avoid surprises.
**Important**: To enable feed updates you will need to enable either [Nextcloud system cron](https://docs.nextcloud.com/server/10/admin_manual/configuration_server/background_jobs_configuration.html#cron) or use [an updater](https://github.com/nextcloud/news-updater) which uses the built in update API and disable cron updates. More information can be found [in the README](https://github.com/nextcloud/news).]]></description>
<version>11.0.0</version>
<version>11.0.1</version>
<licence>agpl</licence>
<author>Bernhard Posselt</author>
<author>Alessandro Cosentino</author>
Expand Down Expand Up @@ -38,28 +38,19 @@ Before you update to a new version, [check the changelog](https://github.com/nex
<nextcloud min-version="12" max-version="12"/>
</dependencies>

<!--<settings>-->
<!--<admin>OCA\News\Settings\Admin</admin>-->
<!--<admin-section>OCA\News\Settings\Section</admin-section>-->
<!--</settings>-->
<background-jobs>
<job>OCA\News\Cron\Updater</job>
</background-jobs>

<settings>
<admin>OCA\News\Settings\Admin</admin>
<admin-section>OCA\News\Settings\Section</admin-section>
</settings>

<navigations>
<navigation>
<name>News</name>
<route>news.page.index</route>
</navigation>
</navigations>

<!-- cron jobs -->
<cron>
<job>OCA\News\Cron\Updater</job>
</cron>

<!-- hooks -->
<hooks>
<hook>
<channel>OC_User::pre_deleteUser</channel>
<subscriber>OCA\News\Hooks\User::deleteUser</subscriber>
</hook>
</hooks>
</info>
139 changes: 0 additions & 139 deletions lib/Config/AppConfig.php

This file was deleted.

51 changes: 0 additions & 51 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use OCP\AppFramework\Http\ContentSecurityPolicy;

use OCA\News\Service\StatusService;
use OCA\News\Config\AppConfig;
use OCA\News\Config\Config;
use OCA\News\Explore\RecommendedSites;
use OCA\News\Explore\RecommendedSiteNotFoundException;
Expand All @@ -35,7 +34,6 @@ class PageController extends Controller {
private $settings;
private $l10n;
private $userId;
private $appConfig;
private $urlGenerator;
private $config;
private $recommendedSites;
Expand All @@ -47,7 +45,6 @@ public function __construct($AppName,
IRequest $request,
IConfig $settings,
IURLGenerator $urlGenerator,
AppConfig $appConfig,
Config $config,
IL10N $l10n,
RecommendedSites $recommendedSites,
Expand All @@ -56,7 +53,6 @@ public function __construct($AppName,
parent::__construct($AppName, $request);
$this->settings = $settings;
$this->urlGenerator = $urlGenerator;
$this->appConfig = $appConfig;
$this->l10n = $l10n;
$this->userId = $UserId;
$this->config = $config;
Expand Down Expand Up @@ -155,53 +151,6 @@ public function updateSettings($showAll, $compact, $preventReadOnScroll,
}
}


/**
* @NoCSRFRequired
* @PublicPage
*
* Generates a web app manifest, according to specs in:
* https://developer.mozilla.org/en-US/Apps/Build/Manifest
*/
public function manifest() {
$config = $this->appConfig->getConfig();

// size of the icons: 128x128 is required by FxOS for all app manifests
$iconSizes = ['128', '512'];
$icons = [];

$locale = str_replace('_', '-', $this->l10n->getLanguageCode());

foreach ($iconSizes as $size) {
$filename = 'app-' . $size . '.png';
if (file_exists(__DIR__ . '/../../img/' . $filename)) {
$icons[$size] = $this->urlGenerator->imagePath($config['id'],
$filename);
}
}


$data = [
"name" => $config['name'],
"type" => 'web',
"default_locale" => $locale,
"description" => $config['description'],
"launch_path" => $this->urlGenerator->linkToRoute(
$config['navigation']['route']),
"icons" => $icons,
"developer" => [
"name" => $config['author'],
"url" => $config['homepage']
]
];

$response = new JSONResponse($data);
$response->addHeader('Content-Type',
'application/x-web-app-manifest+json');

return $response;
}

/**
* @NoAdminRequired
*
Expand Down
42 changes: 27 additions & 15 deletions lib/Cron/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,46 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Alessandro Cosentino <[email protected]>
* @author Bernhard Posselt <[email protected]>
* @copyright Alessandro Cosentino 2012
* @copyright Bernhard Posselt 2012, 2014
*/

namespace OCA\News\Cron;

use OCA\News\AppInfo\Application;
use OC\BackgroundJob\Job;

use OCA\News\Config\Config;
use OCA\News\Service\StatusService;
use OCA\News\Utility\Updater as UpdaterService;

class Updater {
class Updater extends Job {

public static function run() {
$app = new Application();
/**
* @var Config
*/
private $config;
/**
* @var StatusService
*/
private $status;
/**
* @var UpdaterService
*/
private $updaterService;

$container = $app->getContainer();
public function __construct(Config $config, StatusService $status,
UpdaterService $updaterService) {
$this->config = $config;
$this->status = $status;
$this->updaterService = $updaterService;
}

// make it possible to turn off cron updates if you use an external
// script to execute updates in parallel
$useCronUpdates = $container->query(Config::class)->getUseCronUpdates();
$isProperlyConfigured = $container->query(StatusService::class)->isProperlyConfigured();
if ($useCronUpdates && $isProperlyConfigured) {
$container->query(UpdaterService::class)->update();
$container->query(UpdaterService::class)->beforeUpdate();
$container->query(UpdaterService::class)->afterUpdate();
protected function run($argument) {
if ($this->config->getUseCronUpdates() &&
$this->status->isProperlyConfigured()) {
$this->updaterService->update();
$this->updaterService->beforeUpdate();
$this->updaterService->afterUpdate();
}
}

Expand Down
Loading

0 comments on commit 53822bb

Please sign in to comment.