1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-02-20 17:54:25 +01:00

Fix merge conflict

This commit is contained in:
Tom Needham 2012-03-02 21:35:48 +00:00
commit 97c67fe734
16 changed files with 165 additions and 210 deletions

View File

@ -28,18 +28,6 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');
addBookmark($_GET['url'], '', 'Read-Later');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
OC_Util::addScript('bookmarks','addBm');
OC_Util::addStyle('bookmarks', 'bookmarks');
$tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
$metadata = getURLMetadata($url);
$tmpl->assign('URL', htmlentities($metadata['url'],ENT_COMPAT,'utf-8'));
$tmpl->assign('TITLE', htmlentities($metadata['title'],ENT_COMPAT,'utf-8'));
$tmpl->printPage();
include 'templates/addBm.php';

View File

@ -30,50 +30,6 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$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)
");
$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));
}
require_once('../bookmarksHelper.php');
$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']);
OC_JSON::success(array('data' => $id));

View File

@ -1,39 +0,0 @@
<?php
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
// $metadata = array();
require '../bookmarksHelper.php';
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
OC_JSON::success(array('data' => $metadata));

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
@ -8,6 +8,7 @@
*/
OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php';
OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php';
OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
@ -15,9 +16,10 @@ $l = new OC_l10n('bookmarks');
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OC_Helper::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
OC_App::registerPersonal('bookmarks', 'settings');
require_once('apps/bookmarks/lib/search.php');
OC_Util::addScript('bookmarks','bookmarksearch');
// Include the migration provider
require_once('apps/bookmarks/lib/migrate.php');
require_once('apps/bookmarks/lib/migrate.php');
OC_Search::registerProvider('OC_Search_Provider_Bookmarks');

View File

@ -75,14 +75,6 @@
<sorting>descending</sorting>
</field>
</index>
<!-- <index>
<name>url</name>
<unique>true</unique>
<field>
<name>url</name>
<sorting>ascending</sorting>
</field>
</index>-->
</declaration>
</table>

View File

@ -3,8 +3,8 @@
<id>bookmarks</id>
<name>Bookmarks</name>
<description>Bookmark manager for ownCloud</description>
<version>0.1</version>
<version>0.2</version>
<licence>AGPL</licence>
<author>Arthur Schiwon</author>
<author>Arthur Schiwon, Marvin Thomas Rabe</author>
<require>2</require>
</info>

View File

@ -70,3 +70,55 @@ function getURLMetadata($url) {
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;
}
}

View File

@ -1,4 +1,8 @@
#content { overflow: auto; }
#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 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; }
.bookmarks_headline {
font-size: large;
@ -12,13 +16,10 @@
padding: 0.5ex;
}
.bookmarks_add {
display: none;
margin-top: 45px;
}
.bookmarks_list {
margin-top: 36px;
overflow: auto;
position: fixed;
top: 6.5em;
}
.bookmarks_addBml {
@ -32,7 +33,7 @@
}
.bookmarks_input {
width: 20em;
width: 8em;
}
.bookmark_actions {
@ -83,4 +84,4 @@
.loading_meta {
display: none;
margin-left: 5px;
}
}

View File

@ -4,13 +4,12 @@ $(document).ready(function() {
function addBookmark(event) {
var url = $('#bookmark_add_url').val();
var title = $('#bookmark_add_title').val();
var tags = $('#bookmark_add_tags').val();
$.ajax({
url: 'ajax/addBookmark.php',
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
success: function(data){
location.href='index.php';
window.close();
}
});
}

View File

@ -3,19 +3,16 @@ var bookmarks_loading = false;
var bookmarks_sorting = 'bookmarks_sorting_recent';
$(document).ready(function() {
$('.bookmarks_addBtn').click(function(event){
$('.bookmarks_add').slideToggle();
});
$(document).ready(function() {
$('#bookmark_add_submit').click(addOrEditBookmark);
$(window).scroll(updateOnBottom);
$('#bookmark_add_url').focusout(getMetadata);
$(window).resize(function () {
fillWindow($('.bookmarks_list'));
});
$(window).resize();
$($('.bookmarks_list')).scroll(updateOnBottom);
$('.bookmarks_list').empty();
getBookmarks();
});
function getBookmarks() {
@ -28,13 +25,19 @@ function getBookmarks() {
url: 'ajax/updateList.php',
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
success: function(bookmarks){
bookmarks_page += 1;
if (bookmarks.data.length) {
bookmarks_page += 1;
}
$('.bookmark_link').unbind('click', recordClick);
$('.bookmark_delete').unbind('click', delBookmark);
$('.bookmark_edit').unbind('click', showBookmark);
for(var i in bookmarks.data) {
updateBookmarksList(bookmarks.data[i]);
$("#firstrun").hide();
}
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
$('.bookmark_link').click(recordClick);
@ -42,24 +45,13 @@ function getBookmarks() {
$('.bookmark_edit').click(showBookmark);
bookmarks_loading = false;
if (bookmarks.data.length) {
updateOnBottom()
}
}
});
}
function getMetadata() {
var url = encodeEntities($('#bookmark_add_url').val());
$('.loading_meta').css('display','inline');
$.ajax({
url: 'ajax/getMeta.php',
data: 'url=' + encodeURIComponent(url),
success: function(pageinfo){
$('#bookmark_add_url').val(pageinfo.data.url);
$('#bookmark_add_title').val(pageinfo.data.title);
$('.loading_meta').css('display','none');
}
});
}
// function addBookmark() {
// Instead of creating editBookmark() function, Converted the one above to
// addOrEditBookmark() to make .js file more compact.
@ -69,28 +61,17 @@ function addOrEditBookmark(event) {
var url = encodeEntities($('#bookmark_add_url').val());
var title = encodeEntities($('#bookmark_add_title').val());
var tags = encodeEntities($('#bookmark_add_tags').val());
var taglist = tags.split(' ');
var tagshtml = '';
for ( var i=0, len=taglist.length; i<len; ++i ){
tagshtml += '<a class="bookmark_tag" href="?tag=' + encodeURI(taglist[i]) + '">' + taglist[i] + '</a> ';
}
$("#firstrun").hide();
if (id == 0) {
$.ajax({
url: 'ajax/addBookmark.php',
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
success: function(response){
var bookmark_id = response.data;
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_list').prepend(
'<div class="bookmark_single" data-id="' + bookmark_id + '" >' +
'<p class="bookmark_actions"><span class="bookmark_delete"><img src="img/delete.png" title="Delete"></span>&nbsp;<span class="bookmark_edit"><img src="img/edit.png" title="Edit"></span></p>' +
'<p class="bookmark_title"><a href="' + url + '" target="_blank" class="bookmark_link">' + title + '</a></p>' +
'<p class="bookmark_tags">' + tagshtml + '</p>' +
'<p class="bookmark_url">' + url + '</p>' +
'</div>'
);
$('.bookmarks_input').val('');
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
@ -99,18 +80,11 @@ function addOrEditBookmark(event) {
url: 'ajax/editBookmark.php',
data: 'id=' + id + '&url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
success: function(){
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_input').val('');
$('#bookmark_add_id').val('0');
var record = $('.bookmark_single[data-id = "' + id + '"]');
record.children('.bookmark_url:first').text(url);
var record_title = record.children('.bookmark_title:first').children('a:first');
record_title.attr('href', url);
record_title.text(title);
record.children('.bookmark_tags:first').html(tagshtml);
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
@ -122,7 +96,12 @@ function delBookmark(event) {
$.ajax({
url: 'ajax/delBookmark.php',
data: 'url=' + encodeURI($(this).parent().parent().children('.bookmark_url:first').text()),
success: function(data){ record.animate({ opacity: 'hide' }, 'fast'); }
success: function(data){
record.remove();
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
}
});
}
@ -152,10 +131,20 @@ function updateBookmarksList(bookmark) {
if(!hasProtocol(bookmark.url)) {
bookmark.url = 'http://' + bookmark.url;
}
if(bookmark.title == '') bookmark.title = bookmark.url;
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="bookmark_actions"><span class="bookmark_delete"><img src="img/delete.png" title="Delete"></span>&nbsp;<span class="bookmark_edit"><img src="img/edit.png" title="Edit"></span></p>' +
'<p class="bookmark_title"><a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a></p>' +
'<p class="bookmark_actions">' +
'<span class="bookmark_edit">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
'</span>' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'</p>' +
'<p class="bookmark_title">'+
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +
'</p>' +
'<p class="bookmark_url">' + encodeEntities(bookmark.url) + '</p>' +
'</div>'
);
@ -166,7 +155,11 @@ function updateBookmarksList(bookmark) {
function updateOnBottom() {
//check wether user is on bottom of the page
if ($('body').height() <= ($(window).height() + $(window).scrollTop())) {
var top = $('.bookmarks_list>:last-child').position().top;
var height = $('.bookmarks_list').height();
// use a bit of margin to begin loading before we are really at the
// bottom
if (top < height * 1.2) {
getBookmarks();
}
}

View File

@ -20,8 +20,8 @@
*
*/
class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
function search($query){
class OC_Search_Provider_Bookmarks implements OC_Search_Provider{
static function search($query){
$results=array();
$offset = 0;
@ -45,6 +45,3 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
return $results;
}
}
new OC_Search_Provider_Bookmarks();
?>

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@ -8,6 +8,4 @@
$tmpl = new OC_Template( 'bookmarks', 'settings');
//OC_Util::addScript('bookmarks','settings');
return $tmpl->fetchPage();

View File

@ -1,7 +1,11 @@
<div class="bookmarks_addBm">
<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>
<p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<?php echo $_['TITLE']; ?>" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Read later - ownCloud</title>
<link rel="stylesheet" href="css/readlater.css">
</head>
<body>
<div class="message"><h1>Saved!</h1></div>
</body>
</html>

View File

@ -0,0 +1,8 @@
<?php
function createBookmarklet() {
$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 quickly:') . '</small>'
. '<a class="bookmarklet" 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('Read later') . '</a>';
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
@ -9,17 +9,18 @@
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />
<div id="controls">
<input type="button" class="bookmarks_addBtn" value="<?php echo $l->t('Add bookmark'); ?>"/>
</div>
<div class="bookmarks_add">
<input type="hidden" id="bookmark_add_id" value="0" />
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" />
<img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />
</div>
<div class="bookmarks_list">
<?php echo $l->t('You have no bookmarks'); ?>
</div>
</div>
<div id="firstrun" style="display: none;">
<?php
echo $l->t('You have no bookmarks');
require_once('bookmarklet.php');
createBookmarklet();
?>
</div>

View File

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@ -8,7 +8,10 @@
?>
<form id="bookmarks">
<fieldset class="personalblock">
<span class="bold"><?php echo $l->t('Bookmarklet:');?></span>&nbsp;<a class="bookmarks_addBml" href="javascript:(function(){url=encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks') })()"><?php echo $l->t('Add page to ownCloud'); ?></a>
<br/><em><?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?></em><br />
<span class="bold"><?php echo $l->t('Bookmarklet <br />');?></span>
<?php
require_once('bookmarklet.php');
createBookmarklet();
?>
</fieldset>
</form>