Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/apps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/reader
diff options
context:
space:
mode:
authorpriyanka-m <priyanka.menghani@gmail.com>2012-10-01 21:18:35 +0400
committerpriyanka-m <priyanka.menghani@gmail.com>2012-10-01 21:18:35 +0400
commit85b83911471094824b9d98e3f624e792b26f62f5 (patch)
tree802deb41ccf3ebc5b55c6fa2a89809ebe5a02dac /reader
parentf6ebd9882afb54fd49a314a6597cf307456fb36e (diff)
New repo reader added
Diffstat (limited to 'reader')
-rwxr-xr-xreader/appinfo/app.php14
-rwxr-xr-xreader/appinfo/info.xml18
-rwxr-xr-xreader/img/reader.pngbin0 -> 496 bytes
-rwxr-xr-xreader/index.php24
-rwxr-xr-xreader/js/.goutputstream-PFE3KW0
-rwxr-xr-xreader/js/integrate.js45
-rwxr-xr-xreader/templates/index.php85
7 files changed, 186 insertions, 0 deletions
diff --git a/reader/appinfo/app.php b/reader/appinfo/app.php
new file mode 100755
index 000000000..ded228616
--- /dev/null
+++ b/reader/appinfo/app.php
@@ -0,0 +1,14 @@
+<?php
+OCP\App::register(array(
+ 'order' => 20,
+ 'id' => 'reader',
+ 'name' => 'reader'));
+
+OCP\App::addNavigationEntry( array(
+ 'id' => 'reader_index',
+ 'order' => 20,
+ 'href' => OCP\Util::linkTo('reader', 'index.php'),
+ 'icon' => OCP\Util::imagePath( 'reader', 'reader.png' ),
+ 'name'=>'Reader'));
+
+?>
diff --git a/reader/appinfo/info.xml b/reader/appinfo/info.xml
new file mode 100755
index 000000000..9a35276b1
--- /dev/null
+++ b/reader/appinfo/info.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<info>
+
+ <id>reader</id>
+
+ <name>Reader</name>
+
+ <description>An eBook reader app</description>
+
+ <version>1.0</version>
+
+ <licence>AGPL</licence>
+
+ <author>Priyanka</author>
+
+ <require>4</require>
+
+</info>
diff --git a/reader/img/reader.png b/reader/img/reader.png
new file mode 100755
index 000000000..b92e4f50a
--- /dev/null
+++ b/reader/img/reader.png
Binary files differ
diff --git a/reader/index.php b/reader/index.php
new file mode 100755
index 000000000..91e76c617
--- /dev/null
+++ b/reader/index.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+* ownCloud - eBook reader application
+*
+* @author Priyanka Menghani
+*
+*/
+
+OCP\User::checkLoggedIn();
+OCP\App::checkAppEnabled('reader');
+OCP\App::setActiveNavigationEntry( 'reader_index' );
+
+OCP\Util::addStyle( 'files', 'files' );
+OCP\Util::addscript( 'reader', 'integrate' );
+
+// Get the current directory from window url.
+$dir = empty($_GET['dir'])?'/':$_GET['dir'];
+
+$tmpl = new OCP\Template( 'reader', 'index', 'user' );
+$tmpl->assign('dir', $dir);
+$tmpl->printPage();
+
+?>
diff --git a/reader/js/.goutputstream-PFE3KW b/reader/js/.goutputstream-PFE3KW
new file mode 100755
index 000000000..e69de29bb
--- /dev/null
+++ b/reader/js/.goutputstream-PFE3KW
diff --git a/reader/js/integrate.js b/reader/js/integrate.js
new file mode 100755
index 000000000..f06c7055f
--- /dev/null
+++ b/reader/js/integrate.js
@@ -0,0 +1,45 @@
+$(document).ready(function() {
+ $('#fileList tr').each(function(){
+ // data-file attribute to contain unescaped filenames.
+ $(this).attr('data-file',decodeURIComponent($(this).attr('data-file')));
+ });
+
+ $('#file_action_panel').attr('activeAction', false);
+
+ // See if url conatins the index 'reader'
+ if(location.href.indexOf("reader")!=-1) {
+ // Perform function on every click of a link, now and in future.
+ $('td.filename a').live('click',function(event) {
+ event.preventDefault();
+ var filename=$(this).parent().parent().attr('data-file');
+ var tr=$('tr').filterAttr('data-file',filename);
+ var mime=$(this).parent().parent().data('mime');
+ var type=$(this).parent().parent().data('type');
+ // Check if clicked link is a pdf file or a directory, perform suitable function.
+ var action=getAction(mime,type);
+ if(action){
+ action(filename);
+ }
+ });
+ }
+});
+
+/* Function that returns suitable function definition to be executed on
+ * click of the file whose mime and type are passed. */
+function getAction(mime,type) {
+ var name;
+ if(mime == 'application/pdf') {
+ name = function (filename){
+ showPDFviewer($('#dir').val(),filename);
+ }
+ }
+ else {
+ name = function (filename){
+ window.location=OC.linkTo('reader', 'index.php') + '&dir='+
+ encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+
+ encodeURIComponent(filename) + '/';
+ }
+ }
+ return name;
+}
+
diff --git a/reader/templates/index.php b/reader/templates/index.php
new file mode 100755
index 000000000..012acc135
--- /dev/null
+++ b/reader/templates/index.php
@@ -0,0 +1,85 @@
+<div id = "controls">
+ <!-- TODO: add controls -->
+ <div id="file_action_panel"></div>
+ <!-- Set dir value to be passed to integrate.js -->
+ <input type="hidden" name="dir" value="<?php echo empty($_['dir'])?'':rtrim($_['dir'],'/') ?>" id="dir">
+</div>
+<div class = "actions"></div>
+<?php
+ // Get the current directory.
+ $dir = empty($_['dir'])?'/':$_['dir'];
+
+ // Search for pdf files in current directory.
+ $pdfs = \OC_FileCache::searchByMime('application', 'pdf', '/'.\OCP\USER::getUser().'/files'.$dir);
+ sort($pdfs);
+
+ // Construct an array, to store pdf files and directory names, in which pdf files reside.
+ $files = array();
+ // Store file info in the file array.
+ foreach ($pdfs as $pdf) {
+ $file_info = pathinfo($pdf);
+ $file = array();
+ $file['dirname'] = $file_info['dirname'];
+ $file['basename'] = $file_info['filename'];
+ $file['filename'] = $file_info['basename'];
+ $file['extension'] = '.'.$file_info['extension'];
+ $files[] = $file;
+ }
+?>
+
+<table>
+ <tbody id = "fileList">
+ <?php
+ // Array to store directory entries, which contain pdfs.
+ $dirs = array();
+ foreach ($files as $file) {
+ // Encode the file and directory names so that they can be used in querying a url.
+ $name = str_replace('+','%20',urlencode($file['filename']));
+ $name = str_replace('%2F','/', $name);
+ $directory = str_replace('+','%20',urlencode($dir));
+ $directory = str_replace('%2F','/', $directory);
+ if ($file['dirname'] == '.') {
+ ?>
+ <!-- Each tr displays a file -->
+ <tr data-file="<?php echo $name;?>" data-type="<?php echo 'file'?>" data-mime="<?php echo 'application/pdf'?>" data-size="3462755" data-write="true" >
+ <td class="filename svg" style="background-image:url(<?php echo OCP\mimetype_icon('application/pdf'); ?>)">
+ <a class="name" href="http://localhost<?php echo \OCP\Util::linkTo('files', 'download.php').'?file='.$directory.$name; ?>" title="">
+ <span class = "nametext">
+ <?php echo htmlspecialchars($file['basename']);?><span class='extension'><?php echo $file['extension'];?></span>
+ </span>
+ </a>
+ </td>
+ </tr>
+ <?php
+ echo '<br>';
+ }
+ else {
+ // Trim the extra slash that we don't need.
+ $dir_name = ltrim($file['dirname'], '/');
+ // Explode the variable to check if the pdf file is contained in a directory.
+ $dir_array = explode('/', $dir_name);
+ // Each tr entry here contains name of a directory which has a link to reader/index.php.
+ // TODO: correct mime type to be rendered explicitly.
+ $d = '<tr data-file="'.$dir_array[0].'" data-type="dir" data-mime="httpd/unix-directory">
+ <td class="filename svg" style="background-image:url('.OCP\mimetype_icon('dir').')">
+ <a class = "name" href = "'.OCP\Util::linkTo('reader', 'index.php').'&dir='.$dir.$dir_array[0].'/">
+ <span class = "nametext">'.
+ htmlspecialchars($dir_array[0]).
+ '</span>
+ </a>
+ </td>
+ </tr>';
+ /* Store the directory entries in an array so that incase 2 pdf files are conatined in a directory
+ * we don't end up printing the directory name twice. */
+ if (!in_array($d, $dirs)) {
+ $dirs[] = $d;
+ echo $d;
+ echo '<br>';
+ }
+ }
+ }
+ ?>
+ </tbody>
+</table>
+
+