[Pkg-owncloud-commits] [owncloud] 106/223: Add interface for adding a public share to a different ownCloud instance

David Prévot taffit at moszumanska.debian.org
Sun Jun 22 01:54:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit cf5a72c10398bb18817cff8ca4dfba4429a97123
Author: Robin Appelman <icewind at owncloud.com>
Date:   Wed May 14 13:29:03 2014 +0200

    Add interface for adding a public share to a different ownCloud instance
---
 apps/files_sharing/ajax/testremote.php  | 17 ++++++++++++++++
 apps/files_sharing/appinfo/routes.php   |  1 +
 apps/files_sharing/css/public.css       | 14 +++++++++++++
 apps/files_sharing/js/external.js       |  4 ++--
 apps/files_sharing/js/public.js         | 36 +++++++++++++++++++++++++++++++++
 apps/files_sharing/templates/public.php | 18 +++++++++++++----
 6 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/apps/files_sharing/ajax/testremote.php b/apps/files_sharing/ajax/testremote.php
new file mode 100644
index 0000000..10ea307
--- /dev/null
+++ b/apps/files_sharing/ajax/testremote.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind at owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+$remote = $_GET['remote'];
+
+if (file_get_contents('https://' . $remote . '/status.php')) {
+	echo 'https';
+} elseif (file_get_contents('http://' . $remote . '/status.php')) {
+	echo 'http';
+}else{
+	echo 'false';
+}
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
index 2d214c8..8ec4382 100644
--- a/apps/files_sharing/appinfo/routes.php
+++ b/apps/files_sharing/appinfo/routes.php
@@ -6,6 +6,7 @@ $this->create('core_ajax_public_preview', '/publicpreview')->action(
 	});
 
 $this->create('sharing_external_add', '/external')->actionInclude('files_sharing/ajax/external.php');
+$this->create('sharing_external_test_remote', '/testremote')->actionInclude('files_sharing/ajax/testremote.php');
 
 // OCS API
 
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index 1bafb78..52b8481 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -87,3 +87,17 @@ thead {
 	width: 300px;
 	max-width: 90%;
 }
+
+.header-right {
+	transition: opacity 500ms ease 0s;
+	-moz-transition: opacity 500ms ease 0s;
+	-ms-transition: opacity 500ms ease 0s;
+	-o-transition: opacity 500ms ease 0s;
+	-webkit-transition: opacity 500ms ease 0s;
+}
+
+.header-right:hover, .header-right.active {
+	opacity: 1;
+	-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+	filter: alpha(opacity=100);
+}
diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js
index 0fa99a1..1e46b35 100644
--- a/apps/files_sharing/js/external.js
+++ b/apps/files_sharing/js/external.js
@@ -22,7 +22,7 @@ $(document).ready(function () {
 			password = password || '';
 			if (add) {
 				addExternalShare(remote, token, owner, name, password).then(function (result) {
-					if (result) {
+					if (result && result !== 'false') {
 						FileList.reload();
 					} else {
 						OC.dialogs.alert('Error adding ' + name, 'Error adding share');
@@ -37,7 +37,7 @@ $(document).ready(function () {
 		}
 	};
 
-	if (window.FileList) {// only run in the files app
+	if (window.FileList && window.FileList.appName === 'Files') {// only run in the files app
 		var hash = location.hash;
 		location.hash = '';
 		var remote = getParameterByName(hash, 'remote');
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index a224840..48db895 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -186,5 +186,41 @@ $(document).ready(function() {
 			});
 		};
 	}
+
+	$('.save-form').submit(function (event) {
+		event.preventDefault();
+
+		var remote = $(this).find('input[type="text"]').val();
+		var token = $('#sharingToken').val();
+		var location = window.location.protocol + '//' + window.location.host + OC.webroot;
+		var owner = $('#save').data('owner');
+		var name = $('#save').data('name');
+
+		var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
+			+ "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) + "&name=" + encodeURIComponent(name);
+
+
+		if (remote.indexOf('://') > 0) {
+			window.location = url;
+		} else {
+			// if no protocol is specified, we automatically detect it by testing https and http
+			// this check needs to happen on the server due to the Content Security Policy directive
+			$.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) {
+				if (protocol !== 'http' && protocol !== 'https') {
+					OC.dialogs.alert(t('files_sharing', 'No ownCloud installation found at {remote}', {remote: remote}),
+						t('files_sharing', 'Invalid ownCloud url'));
+				} else {
+					window.location = protocol + '://' + url;
+				}
+			});
+		}
+	});
+
+	$('#save > button').click(function () {
+		$(this).hide();
+		$('.header-right').addClass('active');
+		$('.save-form').css('display', 'inline');
+		$('#remote_address').focus();
+	});
 });
 
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 7b5f603..1c0570c 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -15,10 +15,20 @@
 		                                                                                          src="<?php print_unescaped(image_path('', 'logo-wide.svg')); ?>" alt="<?php p($theme->getName()); ?>" /></a>
 		<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
 		<div class="header-right">
-			<a href="<?php p($_['downloadURL']); ?>" id="download" class="button">
-				<img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/>
-				<?php p($l->t('Download'))?>
-			</a>
+			<span id="details">
+				<span id="save" data-owner="<?php p($_['displayName'])?>" data-name="<?php p($_['filename'])?>">
+					<button><?php p($l->t('Save to ownCloud')) ?></button>
+					<form class="save-form hidden" action="#">
+						<input type="text" id="remote_address" placeholder="<?php p($l->t('example.com/owncloud')) ?>"/>
+						<input type="submit" value="<?php p($l->t('Save')) ?>"/>
+					</form>
+				</span>
+				<a href="<?php p($_['downloadURL']); ?>" id="download" class="button">
+					<img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/>
+					<?php p($l->t('Download'))?>
+				</a>
+				<?php p($l->t('shared by %s', array($_['displayName']))) ?>
+			</span>
 		</div>
 </div></header>
 <div id="content">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list