From f95c7f2fae4c8c470578e74c107854f80c9e14d0 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Thu, 7 Nov 2013 23:53:06 +0000 Subject: [PATCH] display lines of code in page footer --- assets/html/_footer.html | 3 +- assets/js/init.js | 10 +++++- include/application/application.h | 1 + src/application/Makefile.am | 1 + src/application/application.c | 1 + src/application/controller/loc/read.c | 49 +++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/application/controller/loc/read.c diff --git a/assets/html/_footer.html b/assets/html/_footer.html index 556098f..f225deb 100644 --- a/assets/html/_footer.html +++ b/assets/html/_footer.html @@ -1,5 +1,6 @@
© 2013 Georg Hopp - -contact-email +contact-email - + diff --git a/assets/js/init.js b/assets/js/init.js index c1a26ab..bf1b9ca 100644 --- a/assets/js/init.js +++ b/assets/js/init.js @@ -22,7 +22,6 @@ $(document).ready(function() { } $("#title").load("/_title.html"); - $("#footer").load("/_footer.html"); $("#main").load(asset); $("#menu").load("/_menu.html", function() { @@ -85,6 +84,15 @@ $(document).ready(function() { }); }); + $("#footer").load("/_footer.html", function (){ + $.getJSON( + "/loc/", + function(data) { + $("#loc").empty().append(data.loc + " lines of C code"); + } + ); + }); + $("#randval").click(function() { sval.stop(); }); diff --git a/include/application/application.h b/include/application/application.h index 4d33964..d2be096 100644 --- a/include/application/application.h +++ b/include/application/application.h @@ -59,6 +59,7 @@ CLASS(Application) { Hash roles_resource_index; const char * version; + const char * loc; }; int applicationLogin(Application, Credential, Session); diff --git a/src/application/Makefile.am b/src/application/Makefile.am index ff1cdf5..f0417b4 100644 --- a/src/application/Makefile.am +++ b/src/application/Makefile.am @@ -24,6 +24,7 @@ CONTROLLER = controller/authenticate/create.c \ controller/user/read.c \ controller/signup/create.c \ controller/version/read.c \ + controller/loc/read.c \ controller/_validate_password_repeat.c \ controller/_process_user_create_args.c diff --git a/src/application/application.c b/src/application/application.c index c9754f7..f2a7db3 100644 --- a/src/application/application.c +++ b/src/application/application.c @@ -68,6 +68,7 @@ applicationCtor(void * _this, va_list * params) } this->version = VERSION; + this->loc = LOC; return 0; } diff --git a/src/application/controller/loc/read.c b/src/application/controller/loc/read.c new file mode 100644 index 0000000..ba26370 --- /dev/null +++ b/src/application/controller/loc/read.c @@ -0,0 +1,49 @@ +/** + * \file + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2013 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define _GNU_SOURCE + +#include +#include + +#include "application/application.h" +#include "hash.h" +#include "session.h" + +#include "utils/memory.h" + +#define LOC_JSON "{\"loc\":\"%s\"}" + +char * +controllerLocRead(Application app, Session sess, Hash args) +{ + char * buffer; + size_t nbuffer; + + nbuffer = snprintf(NULL, 0, LOC_JSON, app->loc? app->loc : ""); + buffer = memMalloc(nbuffer); + sprintf(buffer, LOC_JSON, app->loc? app->loc : ""); + + return buffer; +} + +// vim: set ts=4 sw=4: