-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fee6bfc
Showing
17 changed files
with
1,030 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: php | ||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
|
||
before_install: | ||
- cd .. | ||
- git clone https://github.com/owncloud/core.git | ||
- mv maps core/apps/ | ||
- cd core | ||
- git submodule init | ||
- git submodule update | ||
- cd apps/maps | ||
|
||
script: | ||
- phpunit tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Authors | ||
|
||
* Sander Brand: <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
owncloud-maps (0.0.1) | ||
* First release |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Maps | ||
Place this app in **owncloud/apps/** | ||
|
||
|
||
## Running tests | ||
After [Installing PHPUnit](http://phpunit.de/getting-started.html) run: | ||
|
||
phpunit tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
namespace OCA\Maps\AppInfo; | ||
|
||
|
||
\OCP\App::addNavigationEntry(array( | ||
// the string under which your app will be referenced in owncloud | ||
'id' => 'maps', | ||
|
||
// sorting weight for the navigation. The higher the number, the higher | ||
// will it be listed in the navigation | ||
'order' => 10, | ||
|
||
// the route that will be shown on startup | ||
'href' => \OCP\Util::linkToRoute('maps.page.index'), | ||
|
||
// the icon that will be shown in the navigation | ||
// this file needs to exist in img/ | ||
'icon' => \OCP\Util::imagePath('maps', 'app.svg'), | ||
|
||
// the title of your application. This will be used in the | ||
// navigation or on the settings page of your app | ||
'name' => \OC_L10N::get('maps')->t('Maps') | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
namespace OCA\Maps\AppInfo; | ||
|
||
|
||
use \OCP\AppFramework\App; | ||
|
||
use \OCA\Maps\Controller\PageController; | ||
|
||
|
||
class Application extends App { | ||
|
||
|
||
public function __construct (array $urlParams=array()) { | ||
parent::__construct('maps', $urlParams); | ||
|
||
$container = $this->getContainer(); | ||
|
||
/** | ||
* Controllers | ||
*/ | ||
$container->registerService('PageController', function($c) { | ||
return new PageController( | ||
$c->query('AppName'), | ||
$c->query('Request'), | ||
$c->query('UserId') | ||
); | ||
}); | ||
|
||
|
||
/** | ||
* Core | ||
*/ | ||
$container->registerService('UserId', function($c) { | ||
return \OCP\User::getUser(); | ||
}); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<info> | ||
<id>maps</id> | ||
<name>Maps</name> | ||
<description>A simple maps app</description> | ||
<licence>agpl</licence> | ||
<author>Sander Brand</author> | ||
<version>0.0.1</version> | ||
<requiremin>7</requiremin> | ||
</info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
namespace OCA\Maps\AppInfo; | ||
|
||
/** | ||
* Create your routes in here. The name is the lowercase name of the controller | ||
* without the controller part, the stuff after the hash is the method. | ||
* e.g. page#index -> PageController->index() | ||
* | ||
* The controller class has to be registered in the application.php file since | ||
* it's instantiated in there | ||
*/ | ||
$application = new Application(); | ||
|
||
$application->registerRoutes($this, array('routes' => array( | ||
array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'), | ||
array('name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'), | ||
))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
namespace OCA\Maps\Controller; | ||
|
||
|
||
use \OCP\IRequest; | ||
use \OCP\AppFramework\Http\TemplateResponse; | ||
use \OCP\AppFramework\Controller; | ||
|
||
class PageController extends Controller { | ||
|
||
private $userId; | ||
|
||
public function __construct($appName, IRequest $request, $userId){ | ||
parent::__construct($appName, $request); | ||
$this->userId = $userId; | ||
} | ||
|
||
|
||
/** | ||
* CAUTION: the @Stuff turn off security checks, for this page no admin is | ||
* required and no CSRF check. If you don't know what CSRF is, read | ||
* it up in the docs or you might create a security hole. This is | ||
* basically the only required method to add this exemption, don't | ||
* add it to any other method if you don't exactly know what it does | ||
* | ||
* @NoAdminRequired | ||
* @NoCSRFRequired | ||
*/ | ||
public function index() { | ||
$params = array('user' => $this->userId); | ||
return new TemplateResponse('maps', 'main', $params); // templates/main.php | ||
} | ||
|
||
|
||
/** | ||
* Simply method that posts back the payload of the request | ||
* @NoAdminRequired | ||
*/ | ||
public function doEcho($echo) { | ||
return array('echo' => $echo); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#hello { | ||
color: red; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
(function ($, OC) { | ||
|
||
$(document).ready(function () { | ||
$('#hello').click(function () { | ||
alert('Hello from your script file'); | ||
}); | ||
|
||
$('#echo').click(function () { | ||
var url = OC.generateUrl('/apps/maps/echo'); | ||
var data = { | ||
echo: $('#echo-content').val() | ||
}; | ||
|
||
$.post(url, data).success(function (response) { | ||
$('#echo-result').text(response.echo); | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
})(jQuery, OC); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<phpunit bootstrap="tests/autoloader.php"></phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
\OCP\Util::addScript('maps', 'script'); | ||
|
||
\OCP\Util::addStyle('maps', 'style'); | ||
|
||
?> | ||
|
||
<p>Hello World <?php p($_['user']) ?></p> | ||
|
||
<p><button id="hello">click me</button></p> | ||
|
||
<p><textarea id="echo-content"> | ||
Send this as ajax | ||
</textarea></p> | ||
<p><button id="echo">Send ajax request</button></p> | ||
|
||
Ajax response: <div id="echo-result"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../3rdparty/Pimple/Pimple.php'; | ||
|
||
|
||
class OC { | ||
public static $server; | ||
public static $session; | ||
} | ||
|
||
// to execute without owncloud, we need to create our own classloader | ||
spl_autoload_register(function ($className){ | ||
if (strpos($className, 'OCA\\') === 0) { | ||
|
||
$path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); | ||
$relPath = __DIR__ . '/../..' . $path; | ||
|
||
if(file_exists($relPath)){ | ||
require_once $relPath; | ||
} | ||
} else if(strpos($className, 'OCP\\') === 0) { | ||
$path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); | ||
$relPath = __DIR__ . '/../../../lib/public' . $path; | ||
|
||
if(file_exists($relPath)){ | ||
require_once $relPath; | ||
} | ||
} else if(strpos($className, 'OC_') === 0) { | ||
$path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); | ||
$relPath = __DIR__ . '/../../../lib/private/' . $path; | ||
|
||
if(file_exists($relPath)){ | ||
require_once $relPath; | ||
} | ||
} else if(strpos($className, 'OC\\') === 0) { | ||
$path = strtolower(str_replace('\\', '/', substr($className, 2)) . '.php'); | ||
$relPath = __DIR__ . '/../../../lib/private' . $path; | ||
|
||
if(file_exists($relPath)){ | ||
require_once $relPath; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* ownCloud - maps | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Sander Brand <[email protected]> | ||
* @copyright Sander Brand 2014 | ||
*/ | ||
|
||
namespace OCA\Maps\Controller; | ||
|
||
|
||
use \OCP\IRequest; | ||
use \OCP\AppFramework\Http\TemplateResponse; | ||
use \OCP\AppFramework\Http\JSONResponse; | ||
|
||
use \OCA\Maps\AppInfo\Application; | ||
|
||
|
||
class PageControllerTest extends \PHPUnit_Framework_TestCase { | ||
|
||
private $container; | ||
|
||
public function setUp () { | ||
$app = new Application(); | ||
$this->container = $app->getContainer(); | ||
} | ||
|
||
|
||
public function testIndex () { | ||
// swap out request | ||
$this->container['Request'] = $this->getMockBuilder('\OCP\IRequest') | ||
->getMock(); | ||
$this->container['UserId'] = 'john'; | ||
|
||
$result = $this->container['PageController']->index(); | ||
|
||
$this->assertEquals(array('user' => 'john'), $result->getParams()); | ||
$this->assertEquals('main', $result->getTemplateName()); | ||
$this->assertTrue($result instanceof TemplateResponse); | ||
} | ||
|
||
|
||
public function testEcho () { | ||
$result = $this->container['PageController']->doEcho('hi'); | ||
|
||
$this->assertEquals(array('echo' => 'hi'), $result); | ||
} | ||
|
||
|
||
} |