-- create server variable for bookmarklet
+create server variable for bookmarklet
+evaluate MVC architecture w/ template system
+add description field
+
+tags:
+ delimit tags with commas in db (?)
+ need UNIQUE field in tags
+ increment tag count on insert
+ decrement tag count on delete
+ if zero delete row
\ No newline at end of file
b = document,
c = encodeURIComponent,
d = w.open(
- 'http://clmpr/put.php?'
+ 'http://clmpr/new.php?'
+ 'url=' + c(b.location)
+ '&title=' + c(b.title)
, 'clmpr_popup'
d.focus()
} , 300)
}
-)();
\ No newline at end of file
+)();
`id` int(9) NOT NULL AUTO_INCREMENT,
`user_id` int(9) NOT NULL,
`title` varchar(255) NOT NULL,
- `url` varchar(255) NOT NULL,
- `tags` varchar(255) NOT NULL,
+ `url` varchar(255) NOT NULL DEFAULT '',
+ `tags` text NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=239 ;
+) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- Table structure for table `users`
`created` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user` (`user`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+
--- /dev/null
+<div id="footer">
+<p>
+ <a class="about" href="/about">about</a> | <a href="https://github.com/quilime/clmpr">source on github</a>
+</p>
+</div>
+
+<script src="/script.js" language="javascript"></script>
<script>
function deleteClump( id, elem ) {
- if (confirm("delete clump?")) {
+ if (confirm("confirm delete")) {
$.post('delete.php', { clump_id : id }, function(result) {
$(elem).hide();
}, 'json');
</script>
<ul class="links">
-<?php for($i = 0; $row = $q->fetch(); $i++ ): ?>
+<?php for($i = 0; $row = $q->fetch(); $i++ ):
+
+
+ # process tags
+ if ($row['tags'] == '')
+ $row['tags'] = array();
+ else
+ $row['tags'] = explode(" ", $row['tags']);
+
+
+?>
<li>
<span class="url">
<?php echo $row['title'] ? $row['title'] : "<title>" ?>
</a>
</span>
-
<span class="meta">
-
- <span>
<?php echo date("Y-m-d", strtotime($row['date'])) ?> by
<a class="uname" href="/?user=<?php echo $row['user'] ?>"><?php echo $row['user'] ?></a>
</span>
-
+
+ <ul class="tags">
- <span class="tags">
- <?php echo $row['tags'] ?>
- </span>
+ <?php foreach($row['tags'] as $tag) : ?>
+ <li><a href="/tags.php?tag=<?=$tag?>"><?=$tag?></a></li>
+ <? endforeach; ?>
+ </ul>
<?php if ($user = get_user()):
if ($user['user'] == $row['user']): ?>
<a href="#" title="Delete" onClick="return deleteClump(<?php echo $row['clump_id']; ?>, this.parentNode);" class="delete">×</a>
<?php endif;
endif; ?>
- </span>
</li>
<script src="/jquery-1.3.2.min.js" language="javascript"></script>
<link href="/style.css" rel="styleSheet" type="text/css" media="screen" />
-<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
\ No newline at end of file
+<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
--- /dev/null
+<div class="header"><a href="/"><b>c</b>itation, <b>l</b>ogging and <b>m</b>ulti-<b>p</b>urpose a<b>r</b>chive</div></a>
+
+<?php include 'signin.php'; ?>
{
case 'about' :
include 'head.html';
- echo "clmpr is a place to save hyperlinks";
- echo '<br /><a href="https://github.com/quilime/clmpr">source on github</a>';
- echo '<br />© 2011 <a href="http://quilime.com">quilime</a>';
+ include 'header.html';
+ echo '<hr />';
+ echo '© 2011 <a href="http://quilime.com">gabriel dunne</a>';
+ echo '<hr />';
+ include 'footer.html';
exit;
default :
<?php include 'head.html'; ?>
</head>
-
<body>
-<div class="header"><b>c</b>itation, <b>l</b>ogging and <b>m</b>ulti-<b>p</b>urpose a<b>r</b>chive</div>
-
-<?php include 'signin.php'; ?>
+<?php include 'header.html'; ?>
<p>
bookmarklet:
<a href="javascript:<?=$js?>">+</a>
</p>
+
<hr />
<?php include 'get.php'; ?>
<hr />
-<div id="footer">
- <a class="about" href="/about">about</a> | <a href="https://github.com/quilime/clmpr">source on github</a>
-</div>
+
+<?php include 'footer.html' ?>
--- /dev/null
+<?php
+
+include 'init.php';
+
+$params = array();
+$params['title'] = isset($_GET['title']) ? $_GET['title'] : null;
+$params['url'] = isset($_GET['url']) ? $_GET['url'] : null;
+
+
+try {
+
+ include 'head.html';
+
+ if ($user = get_user()) {
+
+ ?>
+
+ <form method="POST" action="put.php" class="new">
+
+ <label>title</label>
+ <input type="text" name="title" value="<?=htmlentities($params['title'])?>">
+
+ <br /><br />
+
+ <label>url</label>
+ <input type="text" name="url" value="<?=$params['url']?>">
+
+ <br /><br />
+
+ <label>tags (space delimited)</label>
+ <input type="text" name="tags" value="">
+
+ <br /><br /><br />
+
+ <input type="submit" value="save">
+ <a href="javascript:window.close();">cancel</a>
+
+ <br />
+ <br />
+
+ </form>
+
+ <!-- <hr /> -->
+
+ <?php // include 'footer.html'; ?>
+
+ <script>
+
+ window.onload = function() {
+ document.forms[0].tags.focus();
+ }
+
+ </script>
+
+
+
+ <?php
+
+ } else {
+
+ include 'signin.php';
+
+ }
+
+
+}
+catch(PDOException $e)
+{
+ echo $e->getMessage();
+}
+
+exit;
include 'init.php';
$params = array();
-$params['title'] = isset($_GET['title']) ? $_GET['title'] : null;
-$params['url'] = isset($_GET['url']) ? $_GET['url'] : null;
+$params['title'] = isset($_POST['title']) ? $_POST['title'] : null;
+$params['url'] = isset($_POST['url']) ? $_POST['url'] : null;
+$params['tags'] = isset($_POST['tags']) ? $_POST['tags'] : null;
-try {
+include 'head.html';
- $dbh = get_db_connection();
- $dbh->beginTransaction();
+try {
if ($user = get_user()) {
- $sql = "INSERT INTO `clmpr`.`clumps` ( `user_id`, `title` , `url` , `date` )
- VALUES ( ?, ?, ?, NOW() ) ";
+ $dbh = get_db_connection();
+ $dbh->beginTransaction();
+
+ # insert clump
+ $sql = "INSERT INTO `clmpr`.`clumps` ( `user_id`, `title` , `url` , `tags`, `date` )
+ VALUES ( ?, ?, ?, ?, NOW() ) ";
$q = $dbh->prepare($sql);
- $count = $q->execute( array( $user['id'], $params['title'],$params['url'] ));
+ $insert = $q->execute( array( $user['id'], $params['title'], $params['url'], $params['tags'] ));
+
+ # process tags
+ $tags = explode(" ", $params['tags']);
+ if (count($tags) > 0) {
+ foreach($tags as $tag) {
+ $sql = "INSERT INTO `clmpr`.`tags` ( `tag` ) VALUES ( ? ) ";
+ $q = $dbh->prepare($sql);
+ $q->execute( array( $tag ));
+ }
+ }
$dbh = null;
echo "clumped.<br/><br/>";
- echo '<a href="javascript:window.close();">ok</a>';
+ //echo '<a href="javascript:window.close();">ok</a>';
+ echo '<script>window.close();</script>';
+
+ include 'foot.html';
} else {
- include 'head.html';
include 'signin.php';
}
--- /dev/null
+// clmpr js
+(function()
+{
+
+
+
+}
+)();
\ No newline at end of file
list-style-type: none;
}
-.header {
+hr {
+ border:0;
+ border-bottom:1px dotted #888;
+}
+
+.header, .header a {
color: #888888;
}
}
ul.links li {
- margin-bottom:1.2em;
+ margin-bottom:0.75em;
}
ul.links li span.url {
display:block;
color:#bbb;
}
ul.links li span.meta a {
- color:#bbb;
+ color:#999;
}
.delete {
font-weight:bold;
padding:0 3px;
line-height:1em;
background:#eee;
+ color:#999;
text-decoration:none;
}
.delete:hover {
text-decoration: none;
}
+
+form.new input[type="text"] {
+ width:100%;
+}
+label {
+ font-weight:bold;
+}
+
+ul.tags, ul.tags li {
+ display:inline;
+}
+ul.tags li {
+ background:#eee;
+ padding:0 4px;
+ margin:0 1px;
+}
+ul.tags li a {
+ color:#aaa;
+}
+
--- /dev/null
+<?php
+
+require_once 'init.php';
+
+$params = array();
+$params['tag'] = isset($_GET['tag']) ? $_GET['tag'] : null;
+
+$dbh = get_db_connection();
+$dbh->beginTransaction();
+
+try {
+ /*
+ if ($params['tag']) {
+ $q = $dbh->prepare("SELECT *, tags.id as tag_id
+ FROM tags
+ WHERE tag = ?
+ ORDER BY tag DESC");
+ $q->execute( array( $params['tag'] ));
+ }
+ else {
+ */
+ $q = $dbh->prepare("SELECT * FROM tags
+ ORDER BY tag DESC");
+ $q->execute();
+ //}
+
+}
+catch(PDOException $e)
+{
+ echo $e->getMessage();
+ exit;
+}
+
+
+?><!DOCTYPE html>
+
+<head>
+<title>clmpr</title>
+
+<?php include 'head.html'; ?>
+
+</head>
+<body>
+
+<?php include 'header.html'; ?>
+
+
+<p>tags</p>
+<hr />
+
+<ul class="tags">
+<?php for($i = 0; $row = $q->fetch(); $i++ ):
+?>
+
+ <li><span class="tag"><a href="<?php echo $row['tag'] ?>"><?php echo $row['tag'] ?></a></span></li>
+
+<?php endfor; ?>
+</ul>
+
+<hr />
+
+<?php include 'footer.html' ?>
+
+
+