Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
added search logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Nov 22, 2013
1 parent f3f6984 commit a8ef613
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 33 deletions.
3 changes: 2 additions & 1 deletion 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

Expand Down
18 changes: 16 additions & 2 deletions client/helpers/router.js
Expand Up @@ -214,7 +214,8 @@ Router.before(filters.nProgressHook, {only: [
'comment_reply',
'user_edit',
'user_profile',
'all-users'
'all-users',
'logs'
]});

Router.before(filters.canView);
Expand All @@ -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

Expand Down Expand Up @@ -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}});
}
});
});
11 changes: 4 additions & 7 deletions client/sass/modules/_users.scss
Expand Up @@ -23,6 +23,7 @@

}
.user-list, .user-table{
font-size: 13px;
.user{
.user-avatar{
height:30px;
Expand All @@ -37,14 +38,16 @@
}
}
table{
width: 100%;
tr{
border-bottom: 1px solid #eee;
td{
padding:10px;
}
}
thead{
tr{
td{
td, th{
font-weight:bold;
}
}
Expand All @@ -57,10 +60,4 @@ table{
}
}

}
.user-table{
font-size: 13px;
tr{
border-bottom: 1px solid #eee;
}
}
48 changes: 25 additions & 23 deletions client/stylesheets/screen.css
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions 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>
9 changes: 9 additions & 0 deletions 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;
},
});
1 change: 1 addition & 0 deletions client/views/common/nav.html
Expand Up @@ -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>
Expand Down
7 changes: 7 additions & 0 deletions collections/searches.js
@@ -0,0 +1,7 @@
Searches = new Meteor.Collection('searches');

Searches.allow({
update: isAdminById
, remove: isAdminById
});

10 changes: 10 additions & 0 deletions server/publications.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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 [];
});
6 changes: 6 additions & 0 deletions server/search.js
@@ -0,0 +1,6 @@
logSearch = function (keyword) {
Searches.insert({
timestamp: new Date().getTime(),
keyword: keyword
})
}

0 comments on commit a8ef613

Please sign in to comment.