Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

554 word frequency for replies #555

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions webapp/_lib/controller/class.PostController.php
Expand Up @@ -31,6 +31,12 @@
*
*/
class PostController extends ThinkUpController {

/**
* Replies Top 20 Words number of reply post min to show option in menu...
*/
const TOP_20_WORDS_POST_MIN = 20;

/**
* View name
* @var str
Expand All @@ -43,6 +49,8 @@ public function control() {
$post_dao = DAOFactory::getDAO('PostDAO');
$this->setPageTitle('Post Details');
$this->setViewTemplate('post.index.tpl');
$this->addToView('top_20_post_min', self::TOP_20_WORDS_POST_MIN);

$network = (isset($_GET['n']) )?$_GET['n']:'twitter';
if ($this->shouldRefreshCache()) {
if ( isset($_GET['t']) && is_numeric($_GET['t']) ) {
Expand Down
7 changes: 6 additions & 1 deletion webapp/_lib/view/_post.tpl
Expand Up @@ -22,7 +22,8 @@
</div>
<div class="grid_3 right small">
{if $t->network == 'twitter' && $username_link != 'internal'}
<a href="http://twitter.com/{$t->author_username}">{$t->author_username}</a>
<a {if $reply_count && $reply_count > $top_20_post_min}id="post_username-{$smarty.foreach.foo.iteration}" {/if}
href="http://twitter.com/{$t->author_username}">{$t->author_username}</a>
{else}
<a href="{$site_root_path}public.php?u={$t->author_username|urlencode}&n={$t->network|urlencode}">
{$t->author_username}
Expand All @@ -39,7 +40,11 @@
<div class="post">
{if $t->post_text}
{if $scrub_reply_username}
{if $reply_count && $reply_count > $top_20_post_min}
<div class="reply_text" id="reply_text-{$smarty.foreach.foo.iteration}">
{/if}
{$t->post_text|regex_replace:"/^@[a-zA-Z0-9_]+/":""|link_usernames_to_twitter}
{if $reply_count && $reply_count > $top_20_post_min}</div>{/if}
{else}
{$t->post_text|link_usernames_to_twitter}
{/if}
Expand Down
33 changes: 33 additions & 0 deletions webapp/_lib/view/_post.word-frequency.tpl
@@ -0,0 +1,33 @@
<div id="word-frequency-div" style="display: none; margin-right: 100px; border: solid gray 1px; padding: 10px;">
<div style="float: left; border: solid black 0px; width: 630px;">
<div id="word-frequency-spinner" style="text-align: center;">
<img src="{$site_root_path}assets/img/loading.gif" width="31" height="31" />
<br />Processing word frequency...
</div>
<div id="word-frequency-list" style="display: none;">
Top 20 Word list:
<div class="word-frequency-div" id="word-frequency-words">
</div>
</div>
</div>

<div style="float: right; width: 27px;">
<a href="#" onclick="return false;" id="word-frequency-close">
<img src="{$site_root_path}assets/img/close-icon.gif" width="27" height="26" /></a>
</div>

<div id="word-frequency-posts-div" style="display: none; position: absolute; background-color: #fff; z-index: 1000;
border: solid black 1px; padding: 10px;">
<div style="float: left; margin: 0px 10px 0px 0px; width: 500px;" id="word-frequency-posts">

</div>
<div style="float: right; width: 27px;">
<img id="word-frequency-posts-close" src="{$site_root_path}assets/img/close-icon.gif" width="27" height="26"
style="cursor: pointer;"/></a>
</div>
<div style="clear: both;"></div>
</div>

<div style="clear: both;"></div>

</div>
32 changes: 22 additions & 10 deletions webapp/_lib/view/post.index.tpl
Expand Up @@ -6,13 +6,16 @@
<div id="nav-sidebar">
<ul id="top-level-sidenav"><br />
{if $post}
<ul class="side-subnav">
<li{if $smarty.get.v eq ''} class="currentview"{/if}><a href="index.php?t={$post->post_id}&n={$post->network}">Post Replies&nbsp;&nbsp;&nbsp;</a></li>
{if $logged_in_user}
<li><a href="#" class="grid_search" title="Search" onclick="return false;"><span id="grid_search_icon">Search & Filter Replies</span></a></li>
{/if}
<li><a href="{$site_root_path}post/export.php?u={$post->author_username}&n={$post->network}&post_id={$post->post_id}&type=replies">Export Replies (CSV)</a></li>
</ul></li>
<ul class="side-subnav">
<li{if $smarty.get.v eq ''} class="currentview"{/if}><a href="index.php?t={$post->post_id}&n={$post->network}">Post Replies&nbsp;&nbsp;&nbsp;</a></li>
{if $logged_in_user}
<li><a href="#" class="grid_search" title="Search" onclick="return false;"><span id="grid_search_icon">Search & Filter Replies</span></a></li>
{/if}
<li><a href="{$site_root_path}post/export.php?u={$post->author_username}&n={$post->network}&post_id={$post->post_id}&type=replies">Export Replies (CSV)</a></li>
{if $post->reply_count_cache > $top_20_post_min}
<li><a href="#" class="grid_search" title="Search" onclick="return false;"><span class="word_frequency">Top 20 Words</span></a></li>
{/if}
</ul></li>
{/if}
{if $sidebar_menu}
{foreach from=$sidebar_menu key=smkey item=sidebar_menu_item name=smenuloop}
Expand Down Expand Up @@ -95,9 +98,18 @@
</div> <!-- end .clearfix -->
{if $replies}
<div class="append_20 clearfix"><br />
{foreach from=$replies key=tid item=t name=foo}
{include file="_post.tpl" t=$t sort='no' scrub_reply_username=true}
{/foreach}
{if $post->reply_count_cache > $top_20_post_min}
{include file="_post.word-frequency.tpl"}
{/if}
<div id="post-replies-div">
{foreach from=$replies key=tid item=t name=foo}
{include file="_post.tpl" t=$t sort='no' scrub_reply_username=true reply_count=$post->reply_count_cache}
{/foreach}
</div>
{if $post->reply_count_cache > $top_20_post_min}
{include file="_post.word-frequency.tpl"}
<script src="{$site_root_path}assets/js/word_frequency" type="text/javascript"></script>
{/if}
{if !$logged_in_user && $private_reply_count > 0}
<span style="font-size:12px">Not showing {$private_reply_count} private repl{if $private_reply_count == 1}y{else}ies{/if}.</span>
{/if}
Expand Down
27 changes: 19 additions & 8 deletions webapp/assets/css/style.css
Expand Up @@ -176,11 +176,22 @@ text-align: center;
#nav-sidebar ul.side-subnav li a:hover {color: white;}
#top-level-sidenav {margin-top:7px}
#nav-sidebar ul.side-subnav .currentview a, #nav-sidebar ul.side-subnav .currentview a:hover {
color: #6184B5;
background-color: #E6E6E6;
-moz-border-radius: 3px;-webkit-border-radius: 3px;
background-color: #e6e6e6;
background: -moz-linear-gradient(top, #FFFFFF, #E6E6E6);
background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#E6E6E6));
border: 0px solid #ddd;
}
color: #6184B5;
background-color: #E6E6E6;
-moz-border-radius: 3px;-webkit-border-radius: 3px;
background-color: #e6e6e6;
background: -moz-linear-gradient(top, #FFFFFF, #E6E6E6);
background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#E6E6E6));
border: 0px solid #ddd;
}

/* word frequency list */
.word-frequency-div div {
float: left;;
list-style-type: none;
background-color: #2a98de;
padding: 1px 4px 1px 4px;
margin: 10px 5px 0px 5px;
}
.word-frequency-count { font-weight: bold; }
.word-frequency-word { cursor: pointer; }