react-native TabNavigator用法

2017-09-06 00:00:00   朋也   react-native学习笔记   react-native TabNavigator  

TabNavigator 也是react-navigation包下的,用法也相当简单

搭建Isso评论服务

2017-08-09 10:30:00   coding4fun   jekyll blog  

与其借助第三方服务天天担心挂,还不如将自己的服务器资源利用起来。Isso就是自建评论系统的一种方式。(官网需要fq.)

Install Isso

测试自Ubuntu服务器。本来官网文档里没那么多戏,但是我一直报错。。又安了很多其它包。

$ sudo apt-get install python3-dev
$ sudo pip install isso
$ sudo apt-get install sqlite3

# 可能需要:
$ sudo pip install werkzeug
$ sudo apt-get install libffi-dev
$ sudo pip install misaka

Configuration

首先新建一个isso配置文件,vi isso.conf,放哪儿都行。

[general]
; database location, check permissions, automatically created if not exists
; your website or blog (not the location of Isso!)
dbpath = xxx/comments.db
name = example
; you can add multiple hosts for local development
; or SSL connections. There is no wildcard to allow
; any domain.
host = http://lszero.com/
notify =
log-file = xxx/isso.log

[server]
listen = http://localhost:8090/

[moderation]
enabled = false
purge-after = 30d

[smtp]
username = username@example.com
password = password
host = smtp.example.com
port = 587
security = starttls
to = your email address
from = "Isso Comment"<username@example.com>
timeout = 10

[markup]
options = strikethrough, superscript, autolink
allowed-elements =
allowed-attributes =

[guard]
enabled = true
ratelimit = 3
direct-reply = 3
reply-to-self = true
require-author = true
require-email = true

...

其中,

  • dbpath 是数据库文件,会自动生成。
  • host 可以添加多个。
  • notify 选择新评论的通知方式。stdout或者smtp
  • listen 设置端口。
  • moderation 是否开启评论审核。若开启,新的评论不会显示,除非你activate。
  • smtp 即设置邮件服务的配置信息。
  • guard 评论防火墙。
  • ratelimit 每个访客一分钟最多可以评论的次数。
  • direct-reply 评论回复次数。
  • reply-to-self 是否可以回复自己的评论,需要配合 JS 引用,下面会说

更多设置选项参见官网文档

运行isso:

$ isso -c /path/to/isso.conf run

反向代理

根据上述配置,isso运行在http://localhost:8090下。我们现在需要通过反向代理功能,目的是让发送到comments.lszero.com的请求被转发到本地isso的端口。

官网给了nginx的配置,我这里也用apache测试了。

with nginx

修改nginx配置:vi /etc/nginx/sites-enabled/default,在开头添加:

server {
    listen 80;
    server_name comments.lszero.com;

    location / {
        proxy_pass http://localhost:8090;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

启动nginx:

sudo service nginx start

有时候nginx配置文件错误,上述命令并没有任何错误提示。

可以通过sudo service nginx status查看是否真的启动了。或者通过sudo nginx -t来测试配置是否正确。

with apache2

配置环境是Ubuntu apache2.

首先要通过a2enmod加载命令加载代理模块:

a2enmod proxy proxy_http

然后添加一个VirtualHost,为了方便,我这里就直接在 /etc/apache2/sites-available/000-default.conf 上改了。

<VirtualHost *:80>
        ServerAdmin intzero@outlook.com
        ServerName comments.lszero.com
        # off表示开启反向代理,on表示开启正向代理
        ProxyRequests Off
        # 将这个虚拟主机跳转到本机的8090端口
        ProxyPass / http://localhost:8090/
        ProxyPassReverse / http://localhost:8090/
        <Proxy *>
                Order Deny,Allow
                Allow from all
        </Proxy>
</VirtualHost>

Test

将下列代码插入你想显示评论功能的位置:

<script data-isso="//comments.lszero.com/"
        src="//comments.lszero.com/js/embed.min.js"></script>

<section id="isso-thread"></section>

这里的更多设置选项参见官网文档。比如开启支持/反对功能,一页显示评论数等。

然后启动web服务和isso:

$ sudo service nginx start   # or 'sudo service apache2 start'
$ isso -c /path/to/isso.conf run

这样就可以了。

小提示:

如果你在发评论自己测试的时候遇到403 Forbidden的错误,你可能是需要修改isso的配置文件,设置reply-to-self = true,让自己可以回复自己。

利用Apache进行多站点配置

2017-08-08 08:30:00   coding   jekyll blog multisites  

用了静态网页之后,主机就空闲了,当初辛辛苦苦跟工信部折腾了好几个月连案都备好了。。总感觉特别亏(其实就是舍不得wordpress的搜索功能。。)转念一想,拿wp当图片上传服务也是不错啊,这样就省去找第三方图床了。

我的目标:

  • www.lszero.com 显示主页面。
  • blog.lszero.com 对应静态site。
  • wp.lszero.com 对应wordpress。

我这里用的是apache来实现的,也可以用nginx。

因为我的测试平台是Ubuntu,故跟网上的配置文件有些不一样。如网上说的apache配置文件http.conf,在我的平台下是/etc/apache2/apache2.conf

Apache下多站点配置

首先修改默认的VirtualHost,然后再添加其他的VirtualHost。

1.sudo vi /etc/apache2/apache2.conf,设置:

ServerName 'www.lszero.com'
<Directory "your_home_page_path">
...
</Directory>

注意该文件的最后两行为:

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

故把新加的站点配置文件放在sites-enabled目录下。

继续,sudo vi /etc/apache2/sites-available/000-default.conf,设置:

DocumentRoot your_home_page_path

2.添加新站点配置文件,并放在sites-available中。

$ cd /etc/apache2/sites-available
$ sudo touch wp-lszero-com.conf
$ sudo touch blog-lszero-com.conf

sudo vi blog-lszero-com.conf,添加:

<VirtualHost *:80>
    ServerAdmin intzero@outlook.com
    ServerName blog.lszero.com
    DocumentRoot your_jekyll_site_path/_site

    <Directory "your_jekyll_site_path/_site">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo vi wp-lszero-com.conf,添加:

<VirtualHost *:80>
    ServerAdmin intzero@outlook.com
    ServerName wp.lszero.com
    DocumentRoot your_wordpress_site_path

    <Directory "your_wordpress_site_path">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

然后建立软链接到sites-enabled目录:

$ cd /etc/apache2/sites-enabled
$ sudo ln -s /etc/apache2/sites-available/www-lszero-com.conf /etc/apache2/sites-enabled/www-lszero-com.conf
$ sudo ln -s /etc/apache2/sites-available/blog-lszero-com.conf /etc/apache2/sites-enabled/blog-lszero-com.conf

重启:

$ sudo service apache2 restart

参考:

flex布局实现上下固定,中间填充满

2017-08-08 00:00:00   朋也   react.js学习笔记   flex css3 react.js  

实现的效果

QQ20170808-154407

react-native组件StackNavigator

2017-08-07 00:00:00   朋也   react-native学习笔记   react-native StackNavigator  

之前一篇文章介绍了使用NavigatorIOS组件结合ListView的使用,但那个只能用在IOS系统上,在Android上就没法用了,所以找到了StackNavigator组件

react-native ListView组件点击跳转

2017-08-02 10:09:30   朋也   react-native学习笔记   react-native ListView  

上一篇 实现了NavigatorIOS与ListView结合使用的方法

这篇文章介绍一下ListView里点击跳转到新视图的方法

先看效果

20180802095850


       9 / 16