mirror of
https://github.com/owncloud/bookmarks.git
synced 2024-11-30 05:24:09 +01:00
Changed bookmarklet to read later widget
This commit is contained in:
parent
7886728fad
commit
ce672c87d1
13
addBm.php
13
addBm.php
@ -27,14 +27,7 @@ require_once('../../lib/base.php');
|
|||||||
OC_Util::checkLoggedIn();
|
OC_Util::checkLoggedIn();
|
||||||
OC_Util::checkAppEnabled('bookmarks');
|
OC_Util::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
|
require_once('bookmarksHelper.php');
|
||||||
|
addBookmark($_GET['url']);
|
||||||
|
|
||||||
OC_Util::addScript('bookmarks','addBm');
|
include 'templates/addBm.php';
|
||||||
OC_Util::addStyle('bookmarks', 'bookmarks');
|
|
||||||
|
|
||||||
$tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
|
|
||||||
|
|
||||||
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
|
|
||||||
$tmpl->assign('URL', htmlentities($url,ENT_COMPAT,'utf-8'));
|
|
||||||
|
|
||||||
$tmpl->printPage();
|
|
||||||
|
@ -30,53 +30,6 @@ require_once('../../../lib/base.php');
|
|||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('bookmarks');
|
OC_JSON::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
|
require_once('../bookmarksHelper.php');
|
||||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']);
|
||||||
$_ut = "strftime('%s','now')";
|
OC_JSON::success(array('data' => $id));
|
||||||
} elseif($CONFIG_DBTYPE == 'pgsql') {
|
|
||||||
$_ut = 'date_part(\'epoch\',now())::integer';
|
|
||||||
} else {
|
|
||||||
$_ut = "UNIX_TIMESTAMP()";
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: Detect when user adds a known URL
|
|
||||||
$query = OC_DB::prepare("
|
|
||||||
INSERT INTO *PREFIX*bookmarks
|
|
||||||
(url, title, user_id, public, added, lastmodified)
|
|
||||||
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
|
||||||
");
|
|
||||||
|
|
||||||
if(empty($_GET["title"])) {
|
|
||||||
require_once('../bookmarksHelper.php');
|
|
||||||
$metadata = getURLMetadata($_GET["url"]);
|
|
||||||
$_GET["title"] = $metadata['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$params=array(
|
|
||||||
htmlspecialchars_decode($_GET["url"]),
|
|
||||||
htmlspecialchars_decode($_GET["title"]),
|
|
||||||
OC_User::getUser()
|
|
||||||
);
|
|
||||||
$query->execute($params);
|
|
||||||
|
|
||||||
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
|
|
||||||
|
|
||||||
if($b_id !== false) {
|
|
||||||
$query = OC_DB::prepare("
|
|
||||||
INSERT INTO *PREFIX*bookmarks_tags
|
|
||||||
(bookmark_id, tag)
|
|
||||||
VALUES (?, ?)
|
|
||||||
");
|
|
||||||
|
|
||||||
$tags = explode(' ', urldecode($_GET["tags"]));
|
|
||||||
foreach ($tags as $tag) {
|
|
||||||
if(empty($tag)) {
|
|
||||||
//avoid saving blankspaces
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$params = array($b_id, trim($tag));
|
|
||||||
$query->execute($params);
|
|
||||||
}
|
|
||||||
|
|
||||||
OC_JSON::success(array('data' => $b_id));
|
|
||||||
}
|
|
@ -70,3 +70,55 @@ function getURLMetadata($url) {
|
|||||||
|
|
||||||
return $metadata;
|
return $metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addBookmark($url, $title='', $tags='') {
|
||||||
|
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
|
||||||
|
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||||
|
$_ut = "strftime('%s','now')";
|
||||||
|
} elseif($CONFIG_DBTYPE == 'pgsql') {
|
||||||
|
$_ut = 'date_part(\'epoch\',now())::integer';
|
||||||
|
} else {
|
||||||
|
$_ut = "UNIX_TIMESTAMP()";
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: Detect when user adds a known URL
|
||||||
|
$query = OC_DB::prepare("
|
||||||
|
INSERT INTO *PREFIX*bookmarks
|
||||||
|
(url, title, user_id, public, added, lastmodified)
|
||||||
|
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
||||||
|
");
|
||||||
|
|
||||||
|
if(empty($title)) {
|
||||||
|
$metadata = getURLMetadata($url);
|
||||||
|
$title = $metadata['title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params=array(
|
||||||
|
htmlspecialchars_decode($url),
|
||||||
|
htmlspecialchars_decode($title),
|
||||||
|
OC_User::getUser()
|
||||||
|
);
|
||||||
|
$query->execute($params);
|
||||||
|
|
||||||
|
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
|
||||||
|
|
||||||
|
if($b_id !== false) {
|
||||||
|
$query = OC_DB::prepare("
|
||||||
|
INSERT INTO *PREFIX*bookmarks_tags
|
||||||
|
(bookmark_id, tag)
|
||||||
|
VALUES (?, ?)
|
||||||
|
");
|
||||||
|
|
||||||
|
$tags = explode(' ', urldecode($tags));
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if(empty($tag)) {
|
||||||
|
//avoid saving blankspaces
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$params = array($b_id, trim($tag));
|
||||||
|
$query->execute($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $b_id;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
#content { overflow: auto; height: 100%; }
|
#content { overflow: auto; height: 100%; }
|
||||||
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
|
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
|
||||||
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
|
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
|
||||||
|
#firstrun .button { font-size: 0.7em; }
|
||||||
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }
|
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }
|
||||||
|
|
||||||
.bookmarks_headline {
|
.bookmarks_headline {
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<div class="bookmarks_addBm">
|
<!DOCTYPE html>
|
||||||
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<?php echo $_['URL']; ?>"/></p>
|
<html lang="en">
|
||||||
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
|
<head>
|
||||||
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
|
<meta charset="utf-8">
|
||||||
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
|
<title>Read later - ownCloud</title>
|
||||||
</div>
|
<link rel="stylesheet" href="css/readlater.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="message"><h1>Saved!</h1></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -3,6 +3,6 @@
|
|||||||
function createBookmarklet() {
|
function createBookmarklet() {
|
||||||
$l = new OC_L10N('bookmarks');
|
$l = new OC_L10N('bookmarks');
|
||||||
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage:') . '</small>'
|
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage:') . '</small>'
|
||||||
. '<a class="button" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=510px,width=550px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
|
. '<a class="button" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
|
||||||
. $l->t('Add page to ownCloud') . '</a>';
|
. $l->t('Read later') . '</a>';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user