Tuesday, March 20, 2018

express pug materialize, router



=============== every time, save file, re-START server ==============
nodemon --exec npm start


npm install express-generator -g

express --view=pug myapp

nodemon can monitor file change and restart server
npm install -g nodemon



with express-pug,  normally start server by
npm start
with Nodemon installed, I use
nodemon --exec npm start
Note: nodemon app.js will NOT work here,
because express.js use start script


============================================================


Pug.js Cheat Sheet



https://codepen.io/mimoduo/post/pug-js-cheat-sheet



Includes

//- Include another pug file
include ./path-to/file.pug

//- Include other file types as plain text
include styles.css
include script.js

#Extends & Blocks

//- template.pug
block data
  - var pageTitle = "Pugcupid"
html
  head
    title= pageTitle
  body
    block ribbon
    block content
      p Pugs fo life
//- page.pug
//- Extends template.pug
extends ./path-to/template.pug

block data
  - var pageTitle = "Pudome"

block ribbon
  p New pug jazz

block content
  p This wipes out "Pugs fo life"



========================================================

http://localhost:3000/index/tmp2/laxxxx/2


var index = require('./routes/index');


app.use('/index', index);


// this is index router, should continue with /index/xxxxxxxxx, not duplicate
// wrong : router.get('/index/:template/:place/:url_id', function(req, res, next) {
router.get('/:template/:place/:url_id', function(req, res, next) {

Monday, March 19, 2018

glassgov force search and




=======================
cleargov1

hoogw, hoogw2000, hoogw2001
pass: aaaa1111


-----------------------------
glassgov1:

hoogw
pass: A1a18113



*************************************************

C:\Apache24\htdocs\glassgov1\view\default\layout.php

footer, 

head, add google ad script


C:\Apache24\htdocs\glassgov1\language\en\common.php

home = Transparent Gov




=======================================

改过以后, search “aaa bbb”
无论是tag 还是topic 必须同时有 aaa 和 bbb 的帖子才出现在搜索结果里,和google search一样。
没改之前,search “aaa bbb”
无论是tag 还是topic, 只有aaa,没有bbb的帖子也出现在搜索结果里。这是不符合google search的原则的。

改这个文件。要加个括号。 (topic or tag) AND (topic or tag) AND (topic or tag)
controller/search.php


///$NormalQuery[] = 't.Topic LIKE :Topic' . $ParamName . ' or t.Tags LIKE :Tag' . $ParamName;
             // joe [2]
 $NormalQuery[] = '('.'t.Topic LIKE :Topic' . $ParamName . ' or t.Tags LIKE :Tag' . $ParamName . ')';
...................
.............
.......
...


///$Temp = implode(' OR ', $NormalQuery);
// joe [1]    (topic or tag) AND (topic or tag) AND (topic or tag)
$Temp = implode(' AND ', $NormalQuery);
...................
.............
.......
...




*************************************************************

发帖,link 的 URL中如果有 “&” 就会失败


替换这个文件src/library/WhiteHTMLFilter.php为新版即可


********************************************************************



++++++++++++++++++++++++++++++++++++++++

搜索提示功能,失败 



我自己改了一下,挺好用的,有同样问题的朋友可以试试,
改这个文件 controller\json.php

干脆不用 dict table
直接搜索 tags table

           `case “tag_autocomplete”:
             。。。。。
              。。。。
               。。。
           
            $Result            = $DB->column("SELECT Name FROM " . PREFIX . "tags WHERE Name LIKE :Keyword limit 10", array(
  "Keyword" => $Keyword . "%"
 ));`

另外再加一个 case, 这个是主页顶上搜 帖子 标题的,大搜索。

     `   case 'searchTopic_autocomplete':

 ..........

           .....................

            $Result            = $DB->column("SELECT Topic FROM " . PREFIX . "topics WHERE Topic LIKE :Keyword limit 10", array(
  "Keyword" => "%". $Keyword . "%"
 ));`

另外一个改动, 原来的tag_autocomplete 改成 searchTopic_autocomplete
static\js\default\global.js
          `$("#SearchInput").autocomplete({
 //serviceUrl: WebsitePath + '/json/tag_autocomplete',
         
            serviceUrl: WebsitePath + '/json/searchTopic_autocomplete',`
这个地方不用改,知道就好。这里是tag 联想提示用的。
static\js\default\new.function.js
$("#AlternativeTag").autocomplete({ serviceUrl: WebsitePath + '/json/tag_autocomplete',








********************************************



去掉:



Website_Statistics


C:\Apache24\htdocs\glassgov1\view\default\home.php

search Website_Statistics


comment this div section


*************************************************








++++++++++++++++++++++


allow registration, close ?



go to mysql, db, table:   carbon_config

set this to false.


CloseRegistration = false



+++++++++++++++++++++++++++++







--------------------

remove logo, extend search box length,



C:\Apache24\htdocs\glassgov1\view\default\layout.php

search logo.png, comment block remove logo




search searchbox
C:\Apache24\htdocs\glassgov1\static\css\default\style.css
search searchbox
change width: 360px; to 560px    /* add 200 */
change width: 264px; to 464px;/*360-(56+4*2)-16*2*/


-------------------------------------
C:\Apache24\htdocs\glassgov1\view\default\layout.php
top nav 3 button move to below, see joe comment
C:\Apache24\htdocs\glassgov1\view\default\sider.php
-------------------------------------------------------




C:\Apache24\htdocs\glassgov1\static\css\default\style.css
search autocomplete-suggestion
change color, style to below:

background: rgba(255,255,255,0.9); /* #F3F3F3; */


autocomplete-selected
background: #F3F3F3; /*#ADE1F4;*/

---------------------------------------------




++++++++++++++++++++++++++++++

remove avatar on each post list

5 files need change

C:\Apache24\htdocs\glassgov1\view\default\home.php
C:\Apache24\htdocs\glassgov1\view\default\search.php
C:\Apache24\htdocs\glassgov1\view\default\recycle_bin.php
C:\Apache24\htdocs\glassgov1\view\default\tag.php
C:\Apache24\htdocs\glassgov1\view\default\tags.php




search item-avatar

comment out the div block


C:\Apache24\htdocs\glassgov1\view\default\topic.php

search detail-avatar
comment out the div block




search "comment-avatar"
C:\Apache24\htdocs\glassgov1\view\default\topic.php

comment out div



++++++++++++++++++++++++++++++++++++++++






Thursday, March 1, 2018

set user path windows

setx path "%path%;C:\Program Files\Microsoft VS Code"