File tree Expand file tree Collapse file tree
app/Http/Controllers/Admin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# mrcoderBlog
22
3+ ## 背景
4+ 博主一直使用git page + hexo搭建个人的博客,奈何,渐渐发现了问题
5+
6+ * seo差的几乎没有
7+ * 访问速度慢的掉渣
8+
9+ 于是本着不重复造轮子的前提下,github上看了开源的blog系统,发现很多都不符合个人的风格,审美,可能是博主用惯了hexo的主题,终下决心自己开发一套。
10+
11+ ## 技术
12+
13+ 完全重新开发是不可能的
14+
15+ * 后台(顺带学习了一下react)
16+ 参考 https://github.com/SadCreeper/laravel-react-blog这位兄跌的开源项目,做了很多更改&优化
17+ * 前端
18+ 参照hexo的next主题,开发了一套,兼容同学们自己开发多个主题
19+
320## 代码部署
421* git clone https://github.com/FrCoderBlog/mrcoderBlog.git blog
522* cd blog
623* composer install
724* composer dump-autoload (加载所有类)
825* php artisan key: generate
9- * 配置.env (新增 BLOG_THEME = next 指定主题)
26+ * 配置.env
27+ BLOG_THEME = next //指定主题
28+ PUSH_STATE = off //自动推送
1029* php artisan migrate (建表)
1130* php artisan db: seed --class=UsersTableSeeder (填充初始密码account: admin @qq.com, pass: admin )
1231* php artisan storage: link
@@ -156,17 +175,36 @@ time=`date "+%Y-%m-%d %H:%M:%S "`
156175echo "${time} sphinx restart success" >> /usr/share/nginx/html/blog/crontab/sphinx.log
157176
158177```
159- 然后定时任务中每小时执行一次该脚本 :
178+ 然后定时任务中每3小时执行一次该脚本 :
160179
161180```
162181crontab -e
163- 0 */1 * * * /usr/share/nginx/html/blog/crontab/indexer.sh
182+ 0 */3 * * * /usr/share/nginx/html/blog/crontab/indexer.sh
164183service crond restart
165184
166185```
167186配置完毕,搜索功能已经可以使用
168187
169-
188+ ## 关于SEO
189+ * 目前支持百度
190+ * js被动推送
191+ 需要别人访问后会自动把链接推给百度
192+ * 主动推送
193+ 需要对项目下crontab目录下的push.sh进行编辑(域名需替换为实际的):
194+ ```
195+ time=`date "+%Y-%m-%d %H:%M:%S "`
196+ echo "${time}" `curl http://www.wrsee.com/admin-api/push` >> push.log
197+ ```
198+ 编辑定时任务:
199+ ```
200+ crontab -e:
201+ //每天下午六点执行推送
202+ 0 18 * * * /usr/share/nginx/html/blog/crontab/indexer.sh
203+ service crond restart
204+
205+ ```
206+
207+
170208
171209## 关于后台的开发
172210后台使用react + antdesign开发
Original file line number Diff line number Diff line change @@ -19,9 +19,17 @@ class PushController extends Controller
1919 */
2020 public function push ()
2121 {
22- $ pushData = $ this ->getPushData ();
23- $ result = $ this ->baiduPush ($ pushData );
24- dd ($ result );
22+ if (env ('PUSH_STATE ' ) == 'on ' ){
23+ $ pushData = $ this ->getPushData ();
24+ $ result = $ this ->baiduPush ($ pushData );
25+ if ($ result ){
26+ return 'push success ' ;
27+ }else {
28+ return 'push fail ' ;
29+ }
30+ }else {
31+ return '自动推送未打开 ' ;
32+ }
2533 }
2634
2735 public function getPushData ()
Original file line number Diff line number Diff line change 1+ time=` date " +%Y-%m-%d %H:%M:%S " `
2+ echo " ${time} " ` curl http://www.vm-blog.com/admin-api/push` >> push.log
3+
4+
Original file line number Diff line number Diff line change 5454 Route::get ('/users/{id} ' , 'UserController@show ' );
5555 Route::post ('/users/{id} ' , 'UserController@update ' );
5656 Route::post ('/users/{id}/password ' , 'UserController@changePassword ' );
57+ });
5758
59+ Route::namespace ('Admin ' )->prefix ('admin-api ' )->group (function () {
5860 Route::get ('/push ' , 'PushController@push ' );
59- });
61+ });
You can’t perform that action at this time.
0 commit comments