use favicon.luchenqun.com get favicon

This commit is contained in:
luchenqun 2019-04-21 12:40:34 +08:00
parent 646b92285d
commit 4753d89b3d
6 changed files with 173 additions and 177 deletions

174
app.js
View File

@ -1,88 +1,88 @@
var express = require('express'); var express = require('express');
var path = require('path'); var path = require('path');
var logger = require('morgan'); var logger = require('morgan');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var session = require('express-session'); var session = require('express-session');
var RedisStore = require('connect-redis')(session); var RedisStore = require('connect-redis')(session);
const secret = 'keyboard cat'; const secret = 'keyboard cat';
var api = require('./routes/api'); var api = require('./routes/api');
var app = express(); var app = express();
var fs = require('fs'); var fs = require('fs');
// 创建下载的目录 // 创建下载的目录
var folders = ['./uploads', './public/images/favicon', './public/images/snap']; var folders = ['./uploads', './public/images/favicon', './public/images/snap'];
folders.forEach((folder) => { folders.forEach((folder) => {
fs.exists(folder, function (exists) { fs.exists(folder, function (exists) {
if (!exists) { if (!exists) {
fs.mkdir(folder, function (err) { fs.mkdir(folder, function (err) {
if (err) console.error(err); if (err) console.error(err);
}); });
} else { } else {
console.log(folder + "is exists!"); console.log(folder + "is exists!");
} }
}); });
}) })
app.use(logger('dev')); app.use(logger('dev'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ app.use(bodyParser.urlencoded({
extended: false extended: false
})); }));
app.use(cookieParser('secret')); app.use(cookieParser('secret'));
app.use(session({ app.use(session({
store: new RedisStore({ store: new RedisStore({
host: "127.0.0.1", host: "127.0.0.1",
port: 6379 port: 6379
}), }),
cookie: { cookie: {
maxAge: 7 * 24 * 60 * 60 * 1000, // 一周 maxAge: 7 * 24 * 60 * 60 * 1000, // 一周
}, },
resave: true, resave: true,
saveUninitialized: true, saveUninitialized: true,
secret: secret secret: secret
})) }))
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));
app.use('/api', api); app.use('/api', api);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function (req, res, next) { app.use(function (req, res, next) {
var err = new Error('Not Found'); var err = new Error('Not Found');
err.status = 404; err.status = 404;
next(err); next(err);
}); });
// error handlers // error handlers
// development error handler // development error handler
// will print stacktrace // will print stacktrace
if (app.get('env') === 'development') { if (app.get('env') === 'development') {
app.use(function (err, req, res, next) { app.use(function (err, req, res, next) {
res.status(err.status || 500); res.status(err.status || 500);
res.render('error', { res.render('error', {
message: err.message, message: err.message,
error: err error: err
}); });
}); });
} }
// production error handler // production error handler
// no stacktraces leaked to user // no stacktraces leaked to user
app.use(function (err, req, res, next) { app.use(function (err, req, res, next) {
res.status(err.status || 500); res.status(err.status || 500);
res.sendfile("./public/404.html"); res.sendfile("./public/404.html");
// res.render('error', { // res.render('error', {
// message: err.message, // message: err.message,
// error: {} // error: {}
// }); // });
}); });
// 卡片这模式就没怎么用过,干掉了。 // 卡片这模式就没怎么用过,干掉了。
// api.checkSnapFaviconState(); // api.checkSnapFaviconState();
// api.getSnapByTimer(); // api.getSnapByTimer();
api.getFaviconByTimer(); // api.getFaviconByTimer();
api.getHotBookmarksByTimer(); api.getHotBookmarksByTimer();
module.exports = app; module.exports = app;

View File

@ -9,7 +9,7 @@ app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$win
$('.ui.modal.js-bookmark-info').modal({ $('.ui.modal.js-bookmark-info').modal({
closable: false, closable: false,
}).modal('setting', 'transition', dataService.animation()).modal('show'); }).modal('setting', 'transition', dataService.animation()).modal('show');
bookmark.favicon_url = bookmark.favicon_url || ('http://favicon.luchenqun.com/?url=' + bookmark.url); bookmark.favicon_url = 'http://favicon.luchenqun.com/?url=' + bookmark.url;
bookmark.snap_url = bookmark.snap_url || ('./images/snap/' + bookmark.id + '.png'); bookmark.snap_url = bookmark.snap_url || ('./images/snap/' + bookmark.id + '.png');
$scope.bookmark = bookmark; $scope.bookmark = bookmark;
$scope.bookmark.description = $sce.trustAsHtml(bookmark.description); $scope.bookmark.description = $sce.trustAsHtml(bookmark.description);

View File

@ -1,74 +1,74 @@
<div class="ui long modal js-bookmark-info" ng-controller="bookmarkInfoCtr" ng-keydown="close()"> <div class="ui long modal js-bookmark-info" ng-controller="bookmarkInfoCtr" ng-keydown="close()">
<i class="close icon"></i> <i class="close icon"></i>
<div class="header"> <div class="header">
{{bookmark.title}} {{bookmark.title}}
</div> </div>
<div class="content"> <div class="content">
<div class="ui grid"> <div class="ui grid">
<div class="sixteen wide column"> <div class="sixteen wide column">
<div class="ui vertically divided grid"> <div class="ui vertically divided grid">
<div class="one column row"> <div class="one column row">
<div class="column"> <div class="column">
<img class="ui middle aligned mini image" ng-src="{{bookmark.favicon_url}}" style="width:16px;height:16px;padding:0;cursor:pointer;" <img class="ui middle aligned mini image" ng-src="{{bookmark.favicon_url}}" style="width:16px;height:16px;padding:0;cursor:pointer;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="./images/favicon/{{bookmark.id}}.ico" ng-click="jumpToUrl(bookmark.url, bookmark.id)"
title="点击跳转到原页面"> title="点击跳转到原页面">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer;" title="点击跳转到原页面">网页地址</span> <span ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer;" title="点击跳转到原页面">网页地址</span>
<span title="点击复制链接" ng-click="copy(bookmark.url)" class="urlSpan">{{bookmark.url}} <span title="点击复制链接" ng-click="copy(bookmark.url)" class="urlSpan">{{bookmark.url}}
<span> <span>
</div> </div>
</div> </div>
<div class="two column row"> <div class="two column row">
<div class="column"> <div class="column">
<i class="add to calendar icon"></i>创建日期: <i class="add to calendar icon"></i>创建日期:
<span>{{bookmark.created_at}}</span> <span>{{bookmark.created_at}}</span>
</div> </div>
<div class="column"> <div class="column">
<i class="calendar icon"></i>最后点击: <i class="calendar icon"></i>最后点击:
<span>{{bookmark.last_click}}</span> <span>{{bookmark.last_click}}</span>
</div> </div>
</div> </div>
<div class="two column row"> <div class="two column row">
<div class="column" ng-if="bookmark.click_count"> <div class="column" ng-if="bookmark.click_count">
<i class="hand pointer icon"></i>点击次数:{{bookmark.click_count}} <i class="hand pointer icon"></i>点击次数:{{bookmark.click_count}}
</div> </div>
<div class="column" ng-if="bookmark.fav_count"> <div class="column" ng-if="bookmark.fav_count">
<i class="heart icon"></i>收藏人数:{{bookmark.fav_count}} <i class="heart icon"></i>收藏人数:{{bookmark.fav_count}}
</div> </div>
<div class="column" ng-if="!bookmark.created_by"> <div class="column" ng-if="!bookmark.created_by">
<i class="tags icon"></i>书签分类: <i class="tags icon"></i>书签分类:
<div class="ui label" ng-repeat="tag in bookmark.tags"> <div class="ui label" ng-repeat="tag in bookmark.tags">
{{ tag.name }} {{ tag.name }}
</div> </div>
</div> </div>
<div class="column" ng-if="bookmark.created_by"> <div class="column" ng-if="bookmark.created_by">
<i class="info circle icon"></i>来源信息:{{bookmark.created_by}} <i class="info circle icon"></i>来源信息:{{bookmark.created_by}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
<div class="content" style="padding:0 10px 0 20px"> <div class="content" style="padding:0 10px 0 20px">
<div class="description"> <div class="description">
<div class="ui header"> <div class="ui header">
描述信息 描述信息
</div> </div>
<pre style="word-break:break-all;white-space: pre-wrap;">{{ bookmark.description }}</pre> <pre style="word-break:break-all;white-space: pre-wrap;">{{ bookmark.description }}</pre>
</div> </div>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
<div class="content" style="padding:0 0 0 20px"> <div class="content" style="padding:0 0 0 20px">
<div class="description"> <div class="description">
<div class="ui header"> <div class="ui header">
内容摘抄 内容摘抄
</div> </div>
<p ng-bind-html="content"></p> <p ng-bind-html="content"></p>
<img class="ui centered medium image" src="/images/loading.gif" ng-show="loading"> <img class="ui centered medium image" src="/images/loading.gif" ng-show="loading">
</div> </div>
</div> </div>
<div class="actions"> <div class="actions">
<div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div> <div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div>
<button class="positive ui right button">关闭页面</button> <button class="positive ui right button">关闭页面</button>
</div> </div>
</div> </div>

View File

@ -30,10 +30,9 @@
id="{{bookmark.id}}"> id="{{bookmark.id}}">
<img <img
class="ui ui middle aligned tiny image bookmarkInfo" class="ui ui middle aligned tiny image bookmarkInfo"
ng-src="./images/favicon/{{bookmark.id}}.ico" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}"
style="width:16px;height:16px;" style="width:16px;height:16px;"
ng-click="detailBookmark(bookmark);$event.stopPropagation()" ng-click="detailBookmark(bookmark);$event.stopPropagation()">
favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}">
<span>{{ bookmark.title}}</span> <span>{{ bookmark.title}}</span>
</div> </div>
</div> </div>
@ -66,10 +65,9 @@
id="{{bookmark.id}}"> id="{{bookmark.id}}">
<img <img
class="ui ui middle aligned tiny image bookmarkInfo" class="ui ui middle aligned tiny image bookmarkInfo"
ng-src="./images/favicon/{{bookmark.id}}.ico" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}"
style="width:16px;height:16px;" style="width:16px;height:16px;"
ng-click="detailBookmark(bookmark);$event.stopPropagation()" ng-click="detailBookmark(bookmark);$event.stopPropagation()">
favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}">
<span>{{ bookmark.title}}</span> <span>{{ bookmark.title}}</span>
</div> </div>
</div> </div>
@ -89,7 +87,7 @@
<tbody> <tbody>
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)"> <tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<td> <td>
<img class="ui ui middle aligned tiny image" ng-src="./images/favicon/{{bookmark.id}}.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"> <img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;"> <span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
{{ bookmark.title }} {{ bookmark.title }}
</span> </span>
@ -142,7 +140,7 @@
</div> </div>
<div class="extra content" ng-show="!bookmark.edit" style="height:50px;padding-right:2px;padding-left:8px;"> <div class="extra content" ng-show="!bookmark.edit" style="height:50px;padding-right:2px;padding-left:8px;">
<span class="left floated like" style="margin-top:6px;"> <span class="left floated like" style="margin-top:6px;">
<img class="ui ui middle aligned tiny image" ng-src="./images/favicon/{{bookmark.id}}.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"> <img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)">
创建于: 创建于:
<span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span> <span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span>
<!-- {{ bookmark.created_at }} --> <!-- {{ bookmark.created_at }} -->

View File

@ -135,17 +135,15 @@
<td> <td>
<img <img
class="ui ui middle aligned mini image" class="ui ui middle aligned mini image"
ng-src="{{ bookmark.favicon_url }}" ng-src="http://favicon.luchenqun.com/?url={{bookmark.favicon_url}}"
style="width:16px;height:16px;cursor:pointer;" style="width:16px;height:16px;cursor:pointer;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)" ng-click="jumpToUrl(bookmark.url, bookmark.id)"
favicon-err="./images/favicon/{{bookmark.id}}.ico"
ng-if="searchHotBookmarks"> ng-if="searchHotBookmarks">
<img <img
class="ui ui middle aligned mini image" class="ui ui middle aligned mini image"
ng-src="./images/favicon/{{bookmark.id}}.ico" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}"
style="width:16px;height:16px;cursor:pointer;" style="width:16px;height:16px;cursor:pointer;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)" ng-click="jumpToUrl(bookmark.url, bookmark.id)"
favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"
ng-if="!searchHotBookmarks"> ng-if="!searchHotBookmarks">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;"> <span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
{{ bookmark.title }} {{ bookmark.title }}

View File

@ -85,8 +85,8 @@
<tbody> <tbody>
<tr ng-repeat="bookmark in bookmarksByTag" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)"> <tr ng-repeat="bookmark in bookmarksByTag" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<td> <td>
<img class="ui ui middle aligned tiny image" ng-src="./images/favicon/{{bookmark.id}}.ico" style="width:16px;height:16px;cursor:pointer;" <img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" style="width:16px;height:16px;cursor:pointer;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"> ng-click="jumpToUrl(bookmark.url, bookmark.id)">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;"> <span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
{{ bookmark.title }} {{ bookmark.title }}
</span> </span>
@ -129,8 +129,8 @@
<div ng-repeat="bookmark in bookmarksByTag" class="column js-costomTag-item" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}" <div ng-repeat="bookmark in bookmarksByTag" class="column js-costomTag-item" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}"
ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)"
ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}"> ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="./images/favicon/{{bookmark.id}}.ico" style="width:16px;height:16px;" <img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" style="width:16px;height:16px;"
ng-click="detailBookmark(bookmark);$event.stopPropagation()" favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"> ng-click="detailBookmark(bookmark);$event.stopPropagation()">
<span>{{ bookmark.title}}</span> <span>{{ bookmark.title}}</span>
</div> </div>
</div> </div>