ref
http://www.pui.ch/phred/archives/2005/05/tags-with-mysql-fulltext.html
+ http://code.google.com/p/mysqlicious/
+
+
--- /dev/null
+<hr />
+<p>
+<b>c</b>itation, <b>l</b>ogging and <b>m</b>ulti-<b>p</b>urpose a<b>r</b>chive
+<br />
+<br />
+</p>
+<p>
+use clmpr (<b>/klum-per/</b>) to save bookmarks.
+<p>
+
+<strong>to use: </strong>
+<?php
+ $js = file_get_contents('bookmarklet.js');
+ $js = str_replace('{BASE_URL}', BASE_URL, $js);
+?>
+drag this link [<a href="javascript:<?=$js?>">+</a>] to your bookmark bar
+<br />
+<br />
+</p>
+
+<p>
+project keywords: <i>
+bookmarks,
+delicious-clone.
+webservice,
+database,
+mindmap,
+citation,
+semantic
+</i>
+<br /><br />
+</p>
+
+<p>
+clmpr is open source. fork the project on <a href="http://github.com/quilime/clmpr">github</a>
+<br />
+<br />
+</p>
+
+
+<!-- echo '© 2011 <a href="http://quilime.com">gabriel dunne</a>'; -->
+<hr />
\ No newline at end of file
`description` text NOT NULL,
`tags` text NOT NULL,
`date` datetime NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `date` (`date`),
+ FULLTEXT KEY `tags` (`tags`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `tags` (
<div id="footer">
<p>
-<a class="about" href="/about">about</a> | <a href="https://github.com/quilime/clmpr">source code</a>
+<a href="http://<?php echo BASE_URL; ?><?php echo $_SERVER['REQUEST_URI'] ?>/.xml">rss</a> | <a class="about" href="/about">about</a> | <a href="https://github.com/quilime/clmpr">source code</a>
</p>
</div>
$pathinfo = pathinfo($_SERVER['REQUEST_URI']);
$format = isset($pathinfo['extension']) ? $pathinfo['extension'] : null;
-$endpoint = '';
-$endpoint = str_replace('.'.$format, '', $endpoint);
$dbh = get_db_connection();
$dbh->beginTransaction();
+$q = null;
+$tag = null;
+
try {
if ($params['user']) {
$user = get_users($dbh, array('user' => $params['user'] ));
ORDER BY date DESC");
$q->execute( array( $params['id'] ));
}
+ else if ($endpoint == 'tag' && isset($urlparts[1])) {
+ $tag = $urlparts[1];
+ $q = $dbh->prepare("SELECT *, clumps.id as clump_id
+ FROM clumps
+ JOIN users
+ ON users.id = clumps.user_id
+ WHERE tags LIKE ?
+ ORDER BY date DESC");
+ $q->execute( array('%'.$tag.'%') );
+ }
else {
$q = $dbh->prepare("SELECT *, clumps.id as clump_id
FROM clumps
<?php include 'header.html'; ?>
+<?php if ($tag) : ?>
+<p>
+<strong><a href="/tags/">tag</a>:</strong> <i><?php echo $tag ?></i>
+</p>
+<?php else: ?>
<p>
bookmarklet:
<?php
?>
<a href="javascript:<?=$js?>">+</a>
</p>
+<?php endif; ?>
-<p>
-<a href="http://<?php echo BASE_URL; ?><?php echo $_SERVER['REQUEST_URI'] ?>.xml">rss</a>
-</p>
<hr />
-
<script>
function deleteClump( id, elem ) {
if (confirm("confirm delete")) {
- $.post('delete.php', { clump_id : id }, function(result) {
+ $.post('/delete.php', { clump_id : id }, function(result) {
$(elem).hide();
}, 'json');
return false;
}
</script>
+
<ul class="links">
-<?php for($i = 0; $row = $q->fetch(); $i++ ):
+<?php if ($q) : for($i = 0; $row = $q->fetch(); $i++ ):
# process description
$hasDescription = $row['description'] || false;
<?php if (count($row['tags']) > 0) : ?>
<ul class="tags">
<?php foreach($row['tags'] as $tag) : ?>
- <li><a href="/tags.php?tag=<?=$tag?>"><?=$tag?></a></li>
+ <li><a href="/tag/<?=$tag?>"><?=$tag?></a></li>
<? endforeach; ?>
</ul>
<?php endif; ?>
<?php if ($user['user'] == $row['user']): ?>
<a href="/edit.php?id=<?php echo $row['clump_id'];?>" class="ui edit">✐</a>
- <a href="#" title="Delete" onClick="return deleteClump(<?php echo $row['clump_id']; ?>, this.parentNode);" class="ui delete">×</a>
+ <a href="#" title="Delete" onClick="return deleteClump(<?php echo $row['clump_id']; ?>, this.parentNode.parentNode);" class="ui delete">×</a>
<?php endif; ?>
</li>
-<?php endfor; ?>
+<?php endfor; endif; ?>
</ul>
$url = isset($_GET['_url']) ? trim($_GET['_url'], '/') : '/';
-list($endpoint) = explode('/', $url);
+$urlparts = explode('/', $url);
+list($endpoint) = $urlparts;
$pathinfo = pathinfo($_SERVER['REQUEST_URI']);
$format = isset($pathinfo['extension']) ? $pathinfo['extension'] : null;
case 'about' :
include 'head.html';
include 'header.html';
- echo '<hr />';
-
- ?>
-
- <p>
- <b>c</b>itation, <b>l</b>ogging and <b>m</b>ulti-<b>p</b>urpose a<b>r</b>chive
- <br />
- <br />
- </p>
-
- <p>
-
- use clmpr (<b>/klum-per/</b>) to save bookmarks.
-
-
-<p>
-
-<strong>to use: </strong>
-<?php
- $js = file_get_contents('bookmarklet.js');
- $js = str_replace('{BASE_URL}', BASE_URL, $js);
-?>
-drag this link [<a href="javascript:<?=$js?>">+</a>] to your bookmark bar
-<br />
-<br />
-</p>
-
-<p>
-project keywords: <i>
-bookmarks,
-delicious-clone.
-webservice,
-database,
-mindmap,
-citation,
-semantic
-</i>
-
-<br /><br />
-</p>
-
-
-
-
-<p>
-clmpr is open source. fork the project on <a href="http://github.com/quilime/clmpr">github</a>
-</p>
-
- <?
-
- //echo '© 2011 <a href="http://quilime.com">gabriel dunne</a>';
- echo '<hr />';
+ include 'about.html';
include 'footer.html';
exit;
+ case 'tag' :
+ case 'tags' :
+ if (count($urlparts) == 1) {
+ include 'tags.php';
+ exit;
+ }
+
default :
if ($endpoint != '') {
$dbh = get_db_connection();
var user = $('#nuser').val();
var pass = $('#npass').val();
$('#register').text("creating user...");
- $.post('signup.php', { user : user, pass : pass }, function(result) {
+ $.post('/signup.php', { user : user, pass : pass }, function(result) {
if (result.success = 'true') {
window.location.reload();
}
var user = $('#user').val();
var pass = $('#pass').val();
$('#signin').text("signing in...");
- $.post('signin.php', { user : user, pass : pass }, function(result) {
+ $.post('/signin.php', { user : user, pass : pass }, function(result) {
window.location.reload();
}, 'json');
}
function onLogout()
{
- $.post('signin.php', { logout : 1 }, function(result) {
+ $.post('/signin.php', { logout : 1 }, function(result) {
$('#signin').html(result.mssg);
window.location.reload();
}, 'json');