chore: 🎉 init project
This commit is contained in:
parent
74cbd8ba9f
commit
f41df55ff2
@ -1,4 +1,4 @@
|
||||
name: app_template
|
||||
name: opds_catalog
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM nextcloud:30
|
||||
|
||||
ARG APP_NAME=app_template
|
||||
ARG APP_NAME=opds_catalog
|
||||
ENV NEXTCLOUD_UPDATE=1
|
||||
ENV NEXTCLOUD_ADMIN_USER=$APP_NAME
|
||||
ENV NEXTCLOUD_ADMIN_PASSWORD=$APP_NAME
|
||||
|
@ -1,27 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
|
||||
<id>app_template</id>
|
||||
<id>opds_catalog</id>
|
||||
<name>App Template</name>
|
||||
<summary>An example summary</summary>
|
||||
<description>An example description</description>
|
||||
<version>1.0.0</version>
|
||||
<licence>agpl</licence>
|
||||
<author mail="example@example.com" homepage="https://example.com">Example</author>
|
||||
<namespace>AppTemplate</namespace>
|
||||
<namespace>OpdsCatalog</namespace>
|
||||
<category>customization</category>
|
||||
<bugs>https://example.com/bugs</bugs>
|
||||
<dependencies>
|
||||
<php min-version="8.1"/>
|
||||
<nextcloud min-version="29" max-version="31"/>
|
||||
</dependencies>
|
||||
<navigations>
|
||||
<navigation>
|
||||
<id>app_template</id>
|
||||
<name>App Template</name>
|
||||
<route>app_template.page.index</route>
|
||||
<icon>app.svg</icon>
|
||||
<type>link</type>
|
||||
</navigation>
|
||||
</navigations>
|
||||
</info>
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "nextcloud/app_template",
|
||||
"name": "nextcloud/opds_catalog",
|
||||
"description": "An example description",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"authors": [
|
||||
@ -11,7 +11,11 @@
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OCA\\AppTemplate\\": "lib/",
|
||||
"OCA\\OpdsCatalog\\": "lib/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"OCP\\": "vendor/nextcloud/ocp/OCP/"
|
||||
}
|
||||
},
|
||||
@ -23,7 +27,9 @@
|
||||
"rector": "rector && composer cs:fix"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1"
|
||||
"php": "^8.1",
|
||||
"kiwilan/php-ebook": "^3.0.04",
|
||||
"kiwilan/php-opds": "^2.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nextcloud/ocp": "^30.0.6",
|
||||
|
2010
composer.lock
generated
Normal file
2010
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\AppTemplate\AppInfo;
|
||||
namespace OCA\OpdsCatalog\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
@ -11,7 +11,7 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
|
||||
class Application extends App implements IBootstrap
|
||||
{
|
||||
public const APP_ID = 'app_template';
|
||||
public const APP_ID = 'opds_catalog';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct(self::APP_ID);
|
||||
|
@ -2,26 +2,61 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\AppTemplate\Controller;
|
||||
namespace OCA\OpdsCatalog\Controller;
|
||||
|
||||
use OCA\AppTemplate\AppInfo\Application;
|
||||
use Kiwilan\Opds\Enums\OpdsVersionEnum;
|
||||
use Kiwilan\Opds\Opds;
|
||||
use Kiwilan\Opds\OpdsConfig;
|
||||
use Kiwilan\Opds\OpdsResponse;
|
||||
use OCA\OpdsCatalog\AppInfo\Application;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\Attribute\OpenAPI;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
private readonly IUser $user,
|
||||
private readonly IURLGenerator $urlGenerator
|
||||
) {
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
}
|
||||
|
||||
#[NoCSRFRequired]
|
||||
#[NoAdminRequired]
|
||||
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/')]
|
||||
public function index(): TemplateResponse {
|
||||
return new TemplateResponse(
|
||||
Application::APP_ID,
|
||||
'index',
|
||||
public function index(): Response {
|
||||
$config = new OpdsConfig(
|
||||
name: $this->user->getDisplayName()."'s Library",
|
||||
author: $this->user->getDisplayName(),
|
||||
iconUrl: $this->urlGenerator->getAbsoluteURL('/avatar/'.$this->user->getUID().'/512'),
|
||||
startUrl: $this->urlGenerator->linkToRoute('opds_catalog.page.index'),
|
||||
searchUrl: $this->urlGenerator->linkToRoute('opds_catalog.page.search')
|
||||
);
|
||||
$opds = Opds::make($config)->get();
|
||||
$response = $opds->getResponse();
|
||||
|
||||
if ($response instanceof OpdsResponse) {
|
||||
if (OpdsVersionEnum::v1Dot2 === $opds->getVersion()) {
|
||||
// @phpstan-ignore-next-line
|
||||
return new DataResponse(data: $response->getContents(), headers: $response->getHeaders());
|
||||
}
|
||||
|
||||
if (OpdsVersionEnum::v2Dot0 === $opds->getVersion()) {
|
||||
// @phpstan-ignore-next-line
|
||||
return new JSONResponse(data: $response->getJson(), headers: $response->getHeaders());
|
||||
}
|
||||
}
|
||||
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "app_template",
|
||||
"name": "opds_catalog",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"engines": {
|
||||
"node": "^20.0.0",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use OCA\AppTemplate\AppInfo\Application;
|
||||
use OCA\OpdsCatalog\AppInfo\Application;
|
||||
use OCP\Util;
|
||||
|
||||
Util::addScript(Application::APP_ID, Application::APP_ID.'-main');
|
||||
|
Loading…
x
Reference in New Issue
Block a user