mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-20 12:11:05 -05:00
kinda working
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
DirectoryIndex index.shtml index.html
|
DirectoryIndex index.shtml index.html
|
||||||
|
AddType text/cache-manifest .manifest
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ cat <<END
|
|||||||
END
|
END
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ln -sf $id.txt tweets.txt # Application cache greptweet.appcache
|
||||||
|
|
||||||
else
|
else
|
||||||
rm -rf $oldpwd/u/$id
|
rm -rf $oldpwd/u/$id
|
||||||
echo '<h1 class="alert alert-error">Sorry the Twitter API is failing. Try again later.</h1>'
|
echo '<h1 class="alert alert-error">Sorry the Twitter API is failing. Try again later.</h1>'
|
||||||
|
|||||||
2
grep.php
2
grep.php
@@ -10,7 +10,7 @@ $QUERY=urldecode(escapeshellarg(urlencode($_GET['q'])));
|
|||||||
//fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n");
|
//fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n");
|
||||||
//fclose($fp);
|
//fclose($fp);
|
||||||
|
|
||||||
exec("grep -hi $QUERY *.txt", $array);
|
exec("grep -hi $QUERY tweets.txt", $array);
|
||||||
$data = json_encode($array);
|
$data = json_encode($array);
|
||||||
echo $_GET['jsoncallback'] . '(' . $data . ');';
|
echo $_GET['jsoncallback'] . '(' . $data . ');';
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html manifest="greptweet.appcache">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Grepping twitter backup</title>
|
<title>Grepping twitter backup</title>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<p class="help-inline">Type a search query like <a href="?foo">foo</a></p>
|
<p class="help-inline">Type a search query like <a href="?foo">foo</a></p>
|
||||||
|
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
<script src="/jquery-1.7.2.min.js"></script>
|
||||||
<script async src="/main.js"></script>
|
<script async src="/main.js"></script>
|
||||||
|
|
||||||
<footer><span id="source"></span></footer>
|
<footer><span id="source"></span></footer>
|
||||||
|
|||||||
40
main.js
40
main.js
@@ -1,6 +1,11 @@
|
|||||||
function grep(query) {
|
function grep(query) {
|
||||||
|
|
||||||
$.getJSON("/u/" + NAME + "/grep.php?jsoncallback=?", { q: query }, function(data) {
|
if (navigator.onLine) {
|
||||||
|
|
||||||
|
$.getJSON("/u/" + NAME + "/grep.php?jsoncallback=?", {
|
||||||
|
q: query
|
||||||
|
},
|
||||||
|
function(data) {
|
||||||
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
||||||
for (var i in data) {
|
for (var i in data) {
|
||||||
tweet = data[i].split('|');
|
tweet = data[i].split('|');
|
||||||
@@ -13,16 +18,36 @@ function grep(query) {
|
|||||||
$('#results').prepend(results + "</ol>");
|
$('#results').prepend(results + "</ol>");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (! lines) {
|
||||||
|
$.get('tweets.txt', function(data) {
|
||||||
|
lines = data.split("\n");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
||||||
|
for (var i = 0; i < lines.length - 1; i++) {
|
||||||
|
tweet = lines[i].split('|');
|
||||||
|
var re = new RegExp(query, 'i');
|
||||||
|
if (tweet[2].match(re)) {
|
||||||
|
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(2) + "</a></li>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#results').prepend(results + "</ol>");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
NAME = window.location.pathname.split('/')[2];
|
NAME = window.location.pathname.split('/')[2];
|
||||||
$("#name").html(NAME);
|
$("#name").html(NAME);
|
||||||
|
|
||||||
$("input[type=search]").change(function() {
|
$("input[type=search]").change(function() {
|
||||||
query = this.value;
|
query = this.value;
|
||||||
window.location.search = query;
|
// window.location.search = query; // Triggers Reload the page to get source for: http://greptweet/u/kaihendry/?food
|
||||||
grep(query);
|
grep(query);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -35,11 +60,14 @@ $(document).ready(function() {
|
|||||||
$("input[type=text]").focus();
|
$("input[type=text]").focus();
|
||||||
|
|
||||||
footer = '<p><a href="' + NAME + '.txt" class="btn primary"><i class="icon-download"></i> Download</a>';
|
footer = '<p><a href="' + NAME + '.txt" class="btn primary"><i class="icon-download"></i> Download</a>';
|
||||||
footer += '<a href="' + "/create.cgi?id=" + NAME +'" class="btn"><i class="icon-refresh"></i> Update</a></p>'
|
footer += '<a href="' + "/create.cgi?id=" + NAME + '" class="btn"><i class="icon-refresh"></i> Update</a></p>';
|
||||||
$("#source").html(footer);
|
$("#source").html(footer);
|
||||||
document.title = "Greptweet " + NAME;
|
document.title = "Greptweet " + NAME;
|
||||||
|
|
||||||
document.cookie = 'u=' + NAME + '; expires=Thu, 2 Aug 2021 20:47:11 UTC; path=/';
|
document.cookie = 'u=' + NAME + '; expires=Thu, 2 Aug 2021 20:47:11 UTC; path=/';
|
||||||
$("#home").click(function(){ document.cookie = 'u=' + NAME + '; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/'; });
|
$("#home").click(function() {
|
||||||
|
document.cookie = 'u=' + NAME + '; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/';
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user