Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stats powered

  • Loading branch information...
commit 24898302f1e783c44038f94cbb5b2c970b5ba698 1 parent 2825f68
@garuma authored
View
10 Apachai.cs
@@ -203,6 +203,12 @@ public void DoPost (IManosContext ctx)
.ContinueWith (cont => DoPictureTasks (ctx, cont.Result, uid, twittertext), TaskContinuationOptions.ExecuteSynchronously);
}
+ [Route ("/Stats")]
+ public void Stats (IManosContext ctx)
+ {
+ HttpServing (ctx, HtmlPaths.StatPage);
+ }
+
void DoPictureTasks (IManosContext ctx, string filename, long uid, string twittertext)
{
var finalUrl = baseServerUrl + "/i/" + filename;
@@ -437,6 +443,7 @@ public void FetchStatistics (IManosContext ctx, string id)
string json;
if (store.TryGetCachedStats (out json)) {
+ Log.Info ("Stats json: " + json);
HandleJson (json, ctx.Response);
return;
}
@@ -448,9 +455,10 @@ public void FetchStatistics (IManosContext ctx, string id)
dict["picNumber"] = picCount;
dict["userNumber"] = userCount;
- dict["latestPics"] = store.GetLastPicturesIds ();
+ dict["latestPics"] = store.GetLastPicturesIds ().Cast<object> ().ToList ();
json = JSON.JsonEncode (dict);
+
store.SetCachedStats (json);
HandleJson (json, ctx.Response);
View
11 Content/css/style.css
@@ -477,17 +477,11 @@ footer #html5_logo {
font-weight: bold;
}
-#picStats {
-}
-
-#userStats {
-}
-
#numberStats {
width: 70%;
margin: auto;
- margin-top: 1em;
- margin-bottom: 2em;
+ margin-top: 2em;
+ margin-bottom: 3em;
}
#numberStats label, #latestSubmissions label {
@@ -507,6 +501,7 @@ footer #html5_logo {
max-width: 150px;
border: 1px solid black;
padding: 1px;
+ visibility: hidden;
}
.cell {
View
92 Content/html/stats.html
@@ -0,0 +1,92 @@
+<!doctype html>
+
+<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
+<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
+<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
+<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
+<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+ <title>Apachaï</title>
+ <meta name="description" content="Apachaï is designed to be a small and lightweight photo and picture sharing application (for services like Twitter) built on the Manos framework">
+ <meta name="author" content="Jérémie Laval">
+
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="shortcut icon" href="/Content/img/favicon.ico">
+ <link rel="apple-touch-icon" href="/Content/img/apachai.png">
+ <link rel="stylesheet" href="/Content/css/style.css?v=1">
+ <link rel="stylesheet" media="handheld" href="/Content/css/handheld.css?v=1">
+ <link rel="stylesheet" media="screen and (max-device-width: 480px)" href="/Content/css/handheld.css?v=1">
+ <script src="/Content/js/libs/modernizr-1.6.min.js"></script>
+</head>
+
+<body>
+
+ <div id="container">
+ <header>
+ <h1><a href="/">Apacha<span class="lastletter">&iuml;</span></a></h1>
+ <h2>Quick picture uploading for the rest of us</h2>
+ </header>
+
+ <div id="main">
+ <div id="maincolumn">
+ <header><h3>The all-mighty statistics page</h3></header>
+ <div id="numberStats">
+ <ul>
+ <li>
+ <div id="picStats" class="numStat">
+ <span id="picNumber" class="number">0</span>
+ <label for="picNumber">photos uploaded on Apachaï</label>
+ </div>
+ </li>
+ <li>
+ <div id="userStats" class="numStat">
+ <span id="userNumber" class="number">0</span>
+ <label for="userNumber">users on Apachaï</label>
+ </div>
+ </li>
+ </ul>
+ </div>
+
+ <div id="latestSubmissions">
+ <label for="submissions">Latest submissions</label>
+ <div id="submissions" class="grid">
+ <div class="row">
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ </div>
+ <div class="row">
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ </div>
+ <div class="row">
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ <div class="cell"><img src="/Content/img/transparent.png" class="pic"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <footer>
+ <a href="https://github.com/garuma/apachai/blob/master/README.md">About</a> | Hosted at <a href="http://neteril.org">Neteril.org</a> | Powered by <a href="http://manosdemono.com/">Manos</a><br><a href="http://www.w3.org/html/logo/"><img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-graphics-performance-semantics.png" id="html5_logo" alt="HTML5 Powered, you better use a good browser" title="HTML5 Powered, you better use a good browser" style="margin-top: 1ex"></a>
+ </footer>
+ </div>
+
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
+ <script>!window.jQuery && document.write(unescape('%3Cscript src="/Content/js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
+
+ <script src="/Content/js/plugins.js"></script>
+ <script src="/Content/js/stats.js?v=1"></script>
+
+ <!--[if lt IE 7 ]>
+ <script src="/Content/js/libs/dd_belatedpng.js"></script>
+ <script> DD_belatedPNG.fix('img, .png_bg'); </script>
+ <![endif]-->
+</body>
+</html>
View
48 Content/js/stats.js
@@ -1,25 +1,33 @@
-var updateFunc = function (data) {
- if (data.length == 0)
- return;
+(function ($) {
+ var updateFunc = function (data) {
+ if (data.length == 0)
+ return;
- var picNumber = data['picNumber'];
- var userNumber = data['userNumber'];
- var latestPics = data['latestPics'];
+ var picNumber = data['picNumber'];
+ var userNumber = data['userNumber'];
+ var latestPics = data['latestPics'];
- $('#picNumber').text(picNumber);
- $('#userNumber').text(userNumber);
+ $('#picNumber').text(picNumber);
+ $('#userNumber').text(userNumber);
- var container = $('#submissions').find('ul');
- latestPics.each (function (key, value) {
- container.append ('<li class="submission"><a href="/i/'+value['id']+'"><ul><li><img src="/Pictures/'+value['id']+'" class="pic"></li><li><span class="tweet">'+value['tweet'].length == 0 ? '<em>(No tweet data to show)</em>' : value['tweet']+'</span></li><li><img class="avatar" src="'+value['avatar']+'"></li></ul></a></li>');
- });
-};
+ var container = $('#submissions .cell');
-$.getJSON('/stats', updateFunc);
+ container.each (function (index) {
+ if (index >= latestPics.length)
+ return;
-(function loop(){
- setTimeout(function(){
- $.getJSON('/stats', updateFunc);
- loop();
- }, 10000);
-})();
+ var img = $(this).children ('img');
+ img.attr ('src', '/Pictures/' + latestPics[index]);
+ img.css ('visibility', 'visible');
+ });
+ };
+
+ $.getJSON('/stats', updateFunc);
+
+ (function loop(){
+ setTimeout(function(){
+ $.getJSON('/stats', updateFunc);
+ loop();
+ }, 10000);
+ })();
+})(window.jQuery);
View
1  HtmlPaths.cs
@@ -33,5 +33,6 @@ public static class HtmlPaths
public static readonly string SignPage = Path.Combine (basePath, "sign.html");
public static readonly string AuthPage = Path.Combine (basePath, "authenticating.html");
public static readonly string HomePage = Path.Combine (basePath, "home.html");
+ public static readonly string StatPage = Path.Combine (basePath, "stats.html");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.