Permalink
Browse files

Added Autocomplete, added Followers/Followees blocks, Taginput widget,

made
Tags
page
sortable,
several
bug
fixes
  • Loading branch information...
snytkine committed Apr 7, 2011
1 parent 82a06a6 commit 1c78883e09f757891c8f995b1f4ef80b93e8fc86
Showing with 1,808 additions and 824 deletions.
  1. +11 −0 !config.ini.dist
  2. +1 −0 RewriteRules.txt
  3. +2 −2 lib/Lampcms/Answers.php
  4. +2 −0 lib/Lampcms/Bodytagger.php
  5. +17 −11 lib/Lampcms/Controllers/Editor.php
  6. +0 −1 lib/Lampcms/Controllers/Getanswers.php
  7. +5 −4 lib/Lampcms/Controllers/Retag.php
  8. +10 −7 lib/Lampcms/Controllers/Search.php
  9. +91 −0 lib/Lampcms/Controllers/Taghint.php
  10. +123 −0 lib/Lampcms/Controllers/Titlehint.php
  11. +6 −0 lib/Lampcms/Controllers/Userinfo.php
  12. +2 −4 lib/Lampcms/Controllers/Users.php
  13. +48 −10 lib/Lampcms/Controllers/Viewqtags.php
  14. +17 −7 lib/Lampcms/Controllers/Viewquestion.php
  15. +24 −9 lib/Lampcms/Controllers/Viewquestions.php
  16. +1 −0 lib/Lampcms/DomFeedItem.php
  17. +37 −30 lib/Lampcms/FollowManager.php
  18. +32 −27 lib/Lampcms/Mailer.php
  19. +110 −45 lib/Lampcms/Modules/Observers/EmailNotifier.php
  20. +30 −15 lib/Lampcms/Modules/Search/MySQL.php
  21. +17 −7 lib/Lampcms/Object.php
  22. +16 −14 lib/Lampcms/ProfileDiv.php
  23. +60 −2 lib/Lampcms/Question.php
  24. +19 −10 lib/Lampcms/QuestionParser.php
  25. +6 −5 lib/Lampcms/Registry.php
  26. +15 −13 lib/Lampcms/Request.php
  27. +26 −0 lib/Lampcms/Responder.php
  28. +191 −7 lib/Lampcms/ShowFollowers.php
  29. +170 −0 lib/Lampcms/String/Tokenizer.php
  30. +1 −1 lib/Lampcms/SubmittedQuestion.php
  31. +27 −58 lib/Lampcms/{TagsNormalizer.php → TagsTokenizer.php}
  32. +26 −40 lib/Lampcms/{Qtitletags.php → TitleTokenizer.php}
  33. +24 −4 lib/Lampcms/UserTagsBlock.php
  34. +2 −2 lib/Lampcms/UserVotesBlock.php
  35. +2 −5 lib/Lampcms/WebPage.php
  36. +3 −0 lighttpd.conf
  37. +0 −9 mysql.sql
  38. +0 −279 stopwords.txt
  39. +21 −0 www/js/min/qa_04022011.js
  40. +22 −0 www/js/min/qa_04072011.js
  41. +201 −29 www/js/qa.js
  42. +186 −64 www/style/1/www/_main.css
  43. +32 −33 www/style/1/www/main.css
  44. +3 −3 www/style/1/www/tplAnstypes.php
  45. +3 −3 www/style/1/www/tplAnswer.php
  46. +2 −2 www/style/1/www/tplComment.php
  47. +1 −1 www/style/1/www/tplFormask.php
  48. +13 −4 www/style/1/www/tplMain.php
  49. +80 −0 www/style/1/www/tplOneFollowee.php
  50. +12 −17 www/style/1/www/tplOneFollower.php
  51. +5 −3 www/style/1/www/tplQlist.php
  52. +1 −1 www/style/1/www/tplQrecent.php
  53. +3 −3 www/style/1/www/tplQtypesdiv.php
  54. +4 −4 www/style/1/www/tplQuestion.php
  55. +2 −2 www/style/1/www/tplQuntypes.php
  56. +10 −2 www/style/1/www/tplSelectrole.php
  57. +4 −4 www/style/1/www/tplTagsort.php
  58. +1 −1 www/style/1/www/tplU3.php
  59. +15 −10 www/style/1/www/tplUserInfo.php
  60. +2 −1 www/style/1/www/tplUserTags.php
  61. +7 −5 www/style/1/www/tplUserVotes.php
  62. +4 −4 www/style/1/www/tplUsertypes.php
View
@@ -158,6 +158,17 @@ SHOW_TIMER = false;
;
GFC_ID =
;
+; disable autocomplete widget
+; in search form and in Title in "Ask" form
+; Autocomplete does send request to server
+; on every key press, and search by title tags
+; is run on server.
+; This is fast process and does
+; not add much load to server but if you
+; still don't want it then set this to true
+; to disable autocomplete
+;
+DISABLE_AUTOCOMPLETE = false
[CAPTCHA]
; to disable captcha for any reason
View
@@ -30,6 +30,7 @@ RewriteRule ^/tags/page([0-9]+)\.htm([l]{0,1})$ /index.php?a=viewqtags&pageID=$1
RewriteRule ^/tags/name([\/]{0,1})$ /index.php?a=viewqtags&cond=name
RewriteRule ^/tags/recent([\/]{0,1})$ /index.php?a=viewqtags&cond=recent
RewriteRule ^/tags/popular([\/]{0,1})$ /index.php?a=viewqtags&cond=popular
+RewriteRule ^/tags/(name|recent|popular)/page([0-9]+)\.html$ /index.php?a=viewqtags&cond=$1&pageID=$2
RewriteRule ^/tagged/(.*)/$ /index.php?a=tagged&tags=$1
RewriteRule ^/tagged/(.*)/page([0-9]+)\.html$ /index.php?a=tagged&tags=$1&pageID=$2
RewriteRule ^/vote/([0-9]+)/(up|down)$ /index.php?a=vote&resid=$1&res=q&type=$2
View
@@ -172,10 +172,10 @@ public function getAnswers(Question $oQuestion, $result = 'html'){
*/
if(!($a['accepted'])){
if($showLink){
- $a['accept_link'] = '<a class="accept" title="'.$alt.'" href="/accept/'.$a['_id'].'">'.$accept.'</a>';
+ $a['accept_link'] = '<a class="accept ttt" title="'.$alt.'" href="/accept/'.$a['_id'].'">'.$accept.'</a>';
}
} else {
- $a['accepted'] = '<img src="/images/accepted.png" alt="Best answer" title="Owner of the question accepted this as best answer">';
+ $a['accepted'] = '<img src="/images/accepted.png" alt="Best answer" class="ttt" title="Owner of the question accepted this as best answer">';
}
$a['nocomments'] = $noComments;
@@ -85,6 +85,8 @@ public static function highlight($mystring, array $aTags){
$key = '/\b'.preg_quote($key).'\b/i';
});
+
+ d('$aTags: '.print_r($aTags, 1));
$ret = preg_replace_callback($aTags, function($matches){
$tag = 'em';
@@ -52,6 +52,7 @@
namespace Lampcms\Controllers;
+
use \Lampcms\Responder;
use \Lampcms\Request;
@@ -122,22 +123,20 @@ protected function process()
$formVals = $this->oForm->getSubmittedValues();
d('formVals: '.print_r($formVals, 1));
- /**
- * @todo for the Anwer object there is no need
- * to worry about the title at all!
- *
- * @todo run the reason through Utf8String also and use htmlentities()
- * instead of strip_tags.
- */
$this->oResource['b'] = $this->makeBody($formVals['qbody']);
+
/**
* Don't attempt to edit the value of title
* for the answer since it technically does not have the title
* and we don't want to change existing one
*/
- if($this->oRequest instanceof \Lampcms\Question){
- $this->oResource['title'] = $this->makeTitle($formVals['title']);
+ if($this->oResource instanceof \Lampcms\Question){
+ $title = $this->makeTitle($formVals['title']);
+ d('title: '.$title);
+ $this->oResource['title'] = $title;
+ $this->oResource['a_title'] = \Lampcms\TitleTokenizer::factory($title)->getArrayCopy();
}
+
$this->oResource->setEdited($this->oRegistry->Viewer, strip_tags($formVals['reason']));
$this->oResource->save();
@@ -177,10 +176,16 @@ protected function makeTitle($title){
protected function updateQuestion(){
if('ANSWERS' === $this->collection){
d('need to update QUESTION');
-
+
try{
$this->oRegistry->Mongo->QUESTIONS
- ->update(array('_id' => $this->oResource['i_qid']), array('$set' => array('i_lm_ts' => time())));
+ ->update(array('_id' => $this->oResource['i_qid']),
+ array(
+ '$set' => array(
+ 'i_lm_ts' => time(),
+ 'i_etag' => time())
+ )
+ );
} catch(\MongoException $e){
d('unable to update question '.$e->getMessage());
}
@@ -191,6 +196,7 @@ protected function updateQuestion(){
protected function returnResult(){
+
Responder::redirectToPage($this->oResource->getUrl());
}
}
@@ -72,7 +72,6 @@ class Getanswers extends Viewquestion
protected $oAnswers;
protected function main(){
-
$this->getQuestion()->getAnswers()->setReturn();
}
@@ -55,7 +55,7 @@
use \Lampcms\Utf8String;
use \Lampcms\WebPage;
use \Lampcms\ReputationAcl;
-use \Lampcms\TagsNormalizer;
+use \Lampcms\TagsTokenizer;
use \Lampcms\Request;
use \Lampcms\Responder;
@@ -83,16 +83,17 @@ class Retag extends WebPage
/**
* Array of submitted tags
- * after they are run through TagsNormalizer
+ * after they are run through TagsTokenizer
*
* @var array
*/
protected $aSubmitted;
protected function main(){
- $this->aSubmitted = TagsNormalizer::parse(Utf8String::factory($this->oRequest['tags']) );
-
+ $this->aSubmitted = TagsTokenizer::factory(Utf8String::factory($this->oRequest['tags']))->getArrayCopy();
+ d('$this->aSubmitted: '.print_r($this->aSubmitted, 1));
+
$this->getQuestion()
->checkPermission()
->checkForChanges()
@@ -63,12 +63,18 @@ class Search extends WebPage
/**
* Search term
- *
+ *
* @var string
*/
protected $term;
-
+ /**
+ * Pagination links on the page
+ * will not be handled by Ajax
+ *
+ * @var bool
+ */
+ protected $notAjaxPaginatable = true;
/**
* (non-PHPdoc)
@@ -83,9 +89,6 @@ protected function main(){
*/
$this->term = $this->oRequest['q'];
$this->aPageVars['qheader'] = '<h1>Search results for: '.$this->term.'</h1>';
- /*if('recent' == $this->oRequest->get('ord', 's', '')){
- $this->order = 'ORDER by ts DESC';
- }*/
$this->aPageVars['title'] = 'Questions matching &#39;'.$this->term.'&#39;';
d('$this->term: '.$this->term);
@@ -126,9 +129,9 @@ protected function makeInfo(){
protected function makeBody(){
-
- $this->aPageVars['body'] = \tplQlist::parse(array('', $this->oSearch->getHtml(), $this->oSearch->getPagerLinks()), false);
+
+ $this->aPageVars['body'] = \tplQlist::parse(array('', $this->oSearch->getHtml(), $this->oSearch->getPagerLinks(), $this->notAjaxPaginatable), false);
return $this;
}
@@ -0,0 +1,91 @@
+<?php
+/**
+ *
+ * License, TERMS and CONDITIONS
+ *
+ * This software is lisensed under the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) version 3
+ * Please read the license here : http://www.gnu.org/licenses/lgpl-3.0.txt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ATTRIBUTION REQUIRED
+ * 4. All web pages generated by the use of this software, or at least
+ * the page that lists the recent questions (usually home page) must include
+ * a link to the http://www.lampcms.com and text of the link must indicate that
+ * the website\'s Questions/Answers functionality is powered by lampcms.com
+ * An example of acceptable link would be "Powered by <a href="http://www.lampcms.com">LampCMS</a>"
+ * The location of the link is not important, it can be in the footer of the page
+ * but it must not be hidden by style attibutes
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This product includes GeoLite data created by MaxMind,
+ * available from http://www.maxmind.com/
+ *
+ *
+ * @author Dmitri Snytkine <cms@lampcms.com>
+ * @copyright 2005-2011 (or current year) ExamNotes.net inc.
+ * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE (LGPL) version 3
+ * @link http://www.lampcms.com Lampcms.com project
+ * @version Release: @package_version@
+ *
+ *
+ */
+
+
+namespace Lampcms\Controllers;
+
+use Lampcms\WebPage;
+use Lampcms\Responder;
+
+/**
+ * Controller for getting array
+ * of tags that partially match the
+ * value of 'q' using "starts with" regex search
+ *
+ * This controller is used from the auto-complete tag widget
+ * on the "Ask" form
+ *
+ * @author Dmitri Snytkine
+ *
+ */
+class Taghint extends Titlehint
+{
+
+ protected function getData(){
+
+ $q = $this->oRequest->get('q', 's');
+ $q = mb_strtolower($q);
+ d('looking for tag hint $q: '.$q);
+
+ try{
+ $cur = $this->oRegistry->Mongo->QUESTION_TAGS->find(
+ array('tag' => array('$regex' => '^'.$q) ), array('tag'))
+ ->sort(array('i_count' => -1))
+ ->limit(200);
+ $this->aData = iterator_to_array($cur, false);
+ d('$this->aData: '.print_r($this->aData, 1));
+ } catch(\MongoException $e){
+ d('MongoException: '.$e->getMessage().' $q was: '.$q);
+ }
+
+ return $this;
+ }
+}
Oops, something went wrong.

0 comments on commit 1c78883

Please sign in to comment.