Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added search logging

  • Loading branch information...
commit a8ef61366faad3c9a4ce592a52d71f0aa0ef6e49 1 parent f3f6984
@SachaG SachaG authored
View
3  History.md
@@ -1,6 +1,7 @@
## v0.7.4 “InterScope”
-* Added basic internationalization (thanks Toam!).
+* Added basic internationalization (thanks Toam!).
+* Added search logging.
## v0.7.3
View
18 client/helpers/router.js
@@ -214,7 +214,8 @@ Router.before(filters.nProgressHook, {only: [
'comment_reply',
'user_edit',
'user_profile',
- 'all-users'
+ 'all-users',
+ 'logs'
]});
Router.before(filters.canView);
@@ -224,7 +225,7 @@ Router.before(filters.isLoggedOut, {only: ['signin', 'signup']});
Router.before(filters.canPost, {only: ['posts_pending', 'comment_reply', 'post_submit']});
Router.before(filters.canEditPost, {only: ['post_edit']});
Router.before(filters.canEditComment, {only: ['comment_edit']});
-Router.before(filters.isAdmin, {only: ['posts_pending', 'all-users', 'settings', 'categories', 'toolbox']});
+Router.before(filters.isAdmin, {only: ['posts_pending', 'all-users', 'settings', 'categories', 'toolbox', 'logs']});
// After Hooks
@@ -594,4 +595,17 @@ Router.map(function() {
this.route('toolbox');
+ // Search Logs
+
+ this.route('logs', {
+ path: '/logs/:limit?',
+ waitOn: function () {
+ var limit = this.params.limit || 100;
+ Session.set('logsLimit', limit);
+ return Meteor.subscribe('searches', limit);
+ },
+ data: function () {
+ return Searches.find({}, {sort: {timestamp: -1}});
+ }
+ });
});
View
11 client/sass/modules/_users.scss
@@ -23,6 +23,7 @@
}
.user-list, .user-table{
+ font-size: 13px;
.user{
.user-avatar{
height:30px;
@@ -37,14 +38,16 @@
}
}
table{
+ width: 100%;
tr{
+ border-bottom: 1px solid #eee;
td{
padding:10px;
}
}
thead{
tr{
- td{
+ td, th{
font-weight:bold;
}
}
@@ -57,10 +60,4 @@ table{
}
}
-}
-.user-table{
- font-size: 13px;
- tr{
- border-bottom: 1px solid #eee;
- }
}
View
48 client/stylesheets/screen.css
@@ -1671,31 +1671,33 @@ input[type="submit"], button, .button, .auth-buttons #login-buttons #login-butto
.filter-sort .sort {
float: right; }
-/* line 27, ../sass/modules/_users.scss */
-.user-list .user .user-avatar, .user-table .user .user-avatar {
- height: 30px;
- width: 30px;
- background-size: 30px 30px;
- display: block;
- -webkit-border-radius: 30px;
- -moz-border-radius: 30px;
- -ms-border-radius: 30px;
- -o-border-radius: 30px;
- border-radius: 30px; }
-
-/* line 41, ../sass/modules/_users.scss */
-table tr td {
- padding: 10px; }
-/* line 47, ../sass/modules/_users.scss */
-table thead tr td {
- font-weight: bold; }
-
-/* line 61, ../sass/modules/_users.scss */
-.user-table {
+/* line 25, ../sass/modules/_users.scss */
+.user-list, .user-table {
font-size: 13px; }
- /* line 63, ../sass/modules/_users.scss */
- .user-table tr {
+ /* line 28, ../sass/modules/_users.scss */
+ .user-list .user .user-avatar, .user-table .user .user-avatar {
+ height: 30px;
+ width: 30px;
+ background-size: 30px 30px;
+ display: block;
+ -webkit-border-radius: 30px;
+ -moz-border-radius: 30px;
+ -ms-border-radius: 30px;
+ -o-border-radius: 30px;
+ border-radius: 30px; }
+
+/* line 40, ../sass/modules/_users.scss */
+table {
+ width: 100%; }
+ /* line 42, ../sass/modules/_users.scss */
+ table tr {
border-bottom: 1px solid #eee; }
+ /* line 44, ../sass/modules/_users.scss */
+ table tr td {
+ padding: 10px; }
+ /* line 50, ../sass/modules/_users.scss */
+ table thead tr td, table thead tr th {
+ font-weight: bold; }
/* line 2, ../sass/modules/_user-profile.scss */
.user-profile .user-avatar {
View
24 client/views/admin/logs.html
@@ -0,0 +1,24 @@
+<template name="logs">
+ <div class="grid-small grid-block dialog admin">
+ <h2>Search Logs</h2>
+ <table>
+ <thead>
+ <tr>
+ <th>Keyword</th>
+ <th>Timestamp</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#each this}}
+ <tr>
+ <td>{{keyword}}</td>
+ <td>{{getTimestamp}}</td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+ <div class="grid more-button">
+ <a class="more-link" href="{{loadMoreUrl}}">{{i18n "Load more"}}</a>
+ </div>
+ </div>
+</template>
View
9 client/views/admin/logs.js
@@ -0,0 +1,9 @@
+Template.logs.helpers({
+ getTimestamp: function () {
+ return moment(this.timestamp).format("M/D, hh:mm:ss");
+ },
+ loadMoreUrl: function(){
+ var count = parseInt(Session.get('logsLimit')) + 100;
+ return '/logs/' + count;
+ },
+});
View
1  client/views/common/nav.html
@@ -38,6 +38,7 @@
<li><a class="users" href="/all-users">{{i18n "Users"}}</a></li>
<li><a class="settings" href="/settings">{{i18n "Settings"}}</a></li>
<li><a class="categories" href="/categories">{{i18n "Categories"}}</a></li>
+ <li><a class="logs" href="/logs">{{i18n "Logs"}}</a></li>
<li><a class="categories" href="/toolbox">{{i18n "Toolbox"}}</a></li>
</ul>
</div>
View
7 collections/searches.js
@@ -0,0 +1,7 @@
+Searches = new Meteor.Collection('searches');
+
+Searches.allow({
+ update: isAdminById
+, remove: isAdminById
+});
+
View
10 server/publications.js
@@ -127,6 +127,8 @@ Meteor.publish('postsList', function(terms) {
if(canViewById(this.userId)){
var parameters = getParameters(terms),
posts = Posts.find(parameters.find, parameters.options);
+ if(terms.query)
+ logSearch(terms.query);
// console.log('//-------- Subscription Parameters:');
// console.log(parameters.find);
// console.log(parameters.options);
@@ -187,3 +189,11 @@ Meteor.publish('categories', function() {
}
return [];
});
+
+Meteor.publish('searches', function(limit) {
+ var limit = typeof limit === undefined ? 20 : limit;
+ if(isAdminById(this.userId)){
+ return Searches.find({}, {limit: limit, sort: {timestamp: -1}});
+ }
+ return [];
+});
View
6 server/search.js
@@ -0,0 +1,6 @@
+logSearch = function (keyword) {
+ Searches.insert({
+ timestamp: new Date().getTime(),
+ keyword: keyword
+ })
+}
Please sign in to comment.
Something went wrong with that request. Please try again.