Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,51 @@ the name for the external site, an icon appears. When this icon is clicked by a
user, the external website appears in the Nextcloud frame. For the user, this
external site appears as if it is part of Nextcloud but, in fact, this can be
any external URL.

## OCS API

It is also possible to get the sites via an OCS endpoint. The request must be authenticated.
Only sites for the user´s language are returned:
```bash
curl -H "OCS-APIRequest: true" \
https://admin:admin@localhost/ocs/v2.php/apps/external/api/v1
```

### Response
```xml
<?xml version="1.0"?>
<ocs>
<meta>
<status>ok</status>
<statuscode>200</statuscode>
<message>OK</message>
</meta>
<data>
<element>
<id>23</id>
<name>Homepage</name>
<url>https://localhost/index.php</url>
<lang>en</lang>
<icon>external.svg</icon>
</element>
</data>
</ocs>
```

### Capability

The app registers a capability, so clients can check that before making the actual OCS request:
```xml
<?xml version="1.0"?>
<ocs>
...
<data>
<capabilities>
...
<external>
<v1>
<element>sites</element>
</v1>
</external>
...
```
43 changes: 0 additions & 43 deletions ajax/setsites.php

This file was deleted.

45 changes: 12 additions & 33 deletions appinfo/app.php
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
<?php

/**
* ownCloud - External app
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
* @license GNU AGPL version 3 or any later version
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

use OCA\External\External;

OCP\App::registerAdmin('external', 'settings');

$sites = External::getSites();
if (!empty($sites)) {
$urlGenerator = \OC::$server->getURLGenerator();
$navigationManager = \OC::$server->getNavigationManager();
for ($i = 0; $i < sizeof($sites); $i++) {
$navigationEntry = function () use ($i, $urlGenerator, $sites) {
return [
'id' => 'external_index' . ($i + 1),
'order' => 80 + $i,
'href' => $urlGenerator->linkToRoute('external_index', ['id'=> $i + 1]),
'icon' => $urlGenerator->imagePath('external', !empty($sites[$i][2]) ? $sites[$i][2] : 'external.svg'),
'name' => $sites[$i][0],
];
};
$navigationManager->add($navigationEntry);
}
}
$app = new \OCA\External\AppInfo\Application();
$app->register();
7 changes: 6 additions & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@
<bugs>https://github.com/nextcloud/external/issues</bugs>
<repository type="git">https://github.com/nextcloud/external.git</repository>

<version>1.2</version>
<version>2.0.0</version>
<namespace>External</namespace>

<dependencies>
<nextcloud min-version="12" max-version="12" />
</dependencies>

<settings>
<admin>OCA\External\Settings\Admin</admin>
</settings>
</info>
37 changes: 29 additions & 8 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
<?php
/**
* Copyright (c) 2014, Lukas Reschke <lukas@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/** @var $this \OCP\Route\IRouter */
$this->create('external_index', '/{id}')
->actionInclude('external/index.php');
$this->create('external_ajax_setsites', 'ajax/setsites.php')
->actionInclude('external/ajax/setsites.php');
return [
'routes' => [
['name' => 'page#showPage', 'url' => '/{id}', 'verb' => 'GET'],
],
'ocs' => [
['name' => 'API#get', 'url' => '/api/{apiVersion}', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v1']],
['name' => 'API#getAdmin', 'url' => '/api/{apiVersion}/sites', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v1']],
['name' => 'API#add', 'url' => '/api/{apiVersion}/sites', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v1']],
['name' => 'API#update', 'url' => '/api/{apiVersion}/sites/{id}', 'verb' => 'PUT', 'requirements' => ['apiVersion' => 'v1', 'id' => '\d+']],
['name' => 'API#delete', 'url' => '/api/{apiVersion}/sites/{id}', 'verb' => 'DELETE', 'requirements' => ['apiVersion' => 'v1', 'id' => '\d+']],
],
];
28 changes: 20 additions & 8 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
.site-url {
width: 250px;
}

#loading_sites {
width: 512px;
}

.delete-button {
display: none;
cursor: pointer;
}

.site_url {
width: 250px;
.invalid-value {
border-color: red !important;
}

.delete_button {
display: none;
li:hover .delete-button {
display: inline-block;
}

.external_sites {
width: 470px;
#ifm {
display: block;
width: 100%;
height: 100%;
}
47 changes: 0 additions & 47 deletions index.php

This file was deleted.

Loading