1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-02-07 06:54:15 +01:00

Rework to have a working popup

This commit is contained in:
Brice Maron 2012-06-26 22:09:55 +00:00
parent 8d59e3b9f0
commit d163d70b92
3 changed files with 18 additions and 14 deletions

View File

@ -27,17 +27,20 @@
OCP\User::checkLoggedIn(); OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks'); OCP\App::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');
if(!isset($_GET['url']) || trim($_GET['url']) == '') { if(!isset($_GET['url']) || trim($_GET['url']) == '') {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
$tmpl = new OCP\Template( '', '404', 'guest' ); $tmpl = new OCP\Template( '', '404', 'guest' );
$tmpl->printPage(); $tmpl->printPage();
exit; exit;
} }elseif(isset($_POST['url'])) {
$bm = addBookmark($_POST['url'], $_POST['title'], implode(' ',$_POST['item']['tags']),$_POST['desc'], $_POST['is_public']);
require_once('bookmarksHelper.php'); OCP\JSON::success(array('id'=>$bm));
exit();
if(isset($_POST['url'])) {
addBookmark($_POST['url'], '', 'Read-Later');
} }
OCP\Util::addscript('bookmarks','tag-it'); OCP\Util::addscript('bookmarks','tag-it');
@ -45,10 +48,12 @@ OCP\Util::addscript('bookmarks','addBm');
OCP\Util::addStyle('bookmarks', 'bookmarks'); OCP\Util::addStyle('bookmarks', 'bookmarks');
OCP\Util::addStyle('bookmarks', 'jquery.tagit'); OCP\Util::addStyle('bookmarks', 'jquery.tagit');
$bm = array('title'=>'hello world', $datas = getURLMetadata($_GET['url']);
$bm = array('title'=> $datas['title'] ? $datas['title'] : '' ,
'url'=> $_GET['url'], 'url'=> $_GET['url'],
'tags'=> array('@admin','music','test'), 'tags'=> array(),
'desc'=>'A fancy description', 'desc'=>'',
'is_public'=>1, 'is_public'=>1,
); );

View File

@ -55,7 +55,6 @@ function getURLMetadata($url) {
$url = 'http://' . $url; $url = 'http://' . $url;
} }
$metadata['url'] = $url; $metadata['url'] = $url;
if (!function_exists('curl_init')){ if (!function_exists('curl_init')){
return $metadata; return $metadata;
} }

View File

@ -5,9 +5,7 @@ $(document).ready(function() {
$('#addBm').submit(bookletSubmit); $('#addBm').submit(bookletSubmit);
$('#tags').tagit({ $('#tags').tagit({
allowSpaces: true, allowSpaces: true,
availableTags: sampleTags, availableTags: sampleTags
itemName: 'item',
fieldName: 'tags',
}); });
}); });
@ -36,7 +34,9 @@ function bookletSubmit(event) {
url: $('#addBm').attr('action'), url: $('#addBm').attr('action'),
data: $('#addBm').serialize(), data: $('#addBm').serialize(),
success: function(data){ success: function(data){
if(data.status == 'success'){
self.close(); self.close();
} }
}
}); });
} }