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

View File

@ -9,7 +9,7 @@ app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$win
$('.ui.modal.js-bookmark-info').modal({
closable: false,
}).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');
$scope.bookmark = bookmark;
$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()">
<i class="close icon"></i>
<div class="header">
{{bookmark.title}}
</div>
<div class="content">
<div class="ui grid">
<div class="sixteen wide column">
<div class="ui vertically divided grid">
<div class="one column row">
<div class="column">
<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"
title="点击跳转到原页面">
<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>
</div>
</div>
<div class="two column row">
<div class="column">
<i class="add to calendar icon"></i>创建日期:
<span>{{bookmark.created_at}}</span>
</div>
<div class="column">
<i class="calendar icon"></i>最后点击:
<span>{{bookmark.last_click}}</span>
</div>
</div>
<div class="two column row">
<div class="column" ng-if="bookmark.click_count">
<i class="hand pointer icon"></i>点击次数:{{bookmark.click_count}}
</div>
<div class="column" ng-if="bookmark.fav_count">
<i class="heart icon"></i>收藏人数:{{bookmark.fav_count}}
</div>
<div class="column" ng-if="!bookmark.created_by">
<i class="tags icon"></i>书签分类:
<div class="ui label" ng-repeat="tag in bookmark.tags">
{{ tag.name }}
</div>
</div>
<div class="column" ng-if="bookmark.created_by">
<i class="info circle icon"></i>来源信息:{{bookmark.created_by}}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui divider"></div>
<div class="content" style="padding:0 10px 0 20px">
<div class="description">
<div class="ui header">
描述信息
</div>
<pre style="word-break:break-all;white-space: pre-wrap;">{{ bookmark.description }}</pre>
</div>
</div>
<div class="ui divider"></div>
<div class="content" style="padding:0 0 0 20px">
<div class="description">
<div class="ui header">
内容摘抄
</div>
<p ng-bind-html="content"></p>
<img class="ui centered medium image" src="/images/loading.gif" ng-show="loading">
</div>
</div>
<div class="actions">
<div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div>
<button class="positive ui right button">关闭页面</button>
</div>
<div class="ui long modal js-bookmark-info" ng-controller="bookmarkInfoCtr" ng-keydown="close()">
<i class="close icon"></i>
<div class="header">
{{bookmark.title}}
</div>
<div class="content">
<div class="ui grid">
<div class="sixteen wide column">
<div class="ui vertically divided grid">
<div class="one column row">
<div class="column">
<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)"
title="点击跳转到原页面">
<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>
</div>
</div>
<div class="two column row">
<div class="column">
<i class="add to calendar icon"></i>创建日期:
<span>{{bookmark.created_at}}</span>
</div>
<div class="column">
<i class="calendar icon"></i>最后点击:
<span>{{bookmark.last_click}}</span>
</div>
</div>
<div class="two column row">
<div class="column" ng-if="bookmark.click_count">
<i class="hand pointer icon"></i>点击次数:{{bookmark.click_count}}
</div>
<div class="column" ng-if="bookmark.fav_count">
<i class="heart icon"></i>收藏人数:{{bookmark.fav_count}}
</div>
<div class="column" ng-if="!bookmark.created_by">
<i class="tags icon"></i>书签分类:
<div class="ui label" ng-repeat="tag in bookmark.tags">
{{ tag.name }}
</div>
</div>
<div class="column" ng-if="bookmark.created_by">
<i class="info circle icon"></i>来源信息:{{bookmark.created_by}}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui divider"></div>
<div class="content" style="padding:0 10px 0 20px">
<div class="description">
<div class="ui header">
描述信息
</div>
<pre style="word-break:break-all;white-space: pre-wrap;">{{ bookmark.description }}</pre>
</div>
</div>
<div class="ui divider"></div>
<div class="content" style="padding:0 0 0 20px">
<div class="description">
<div class="ui header">
内容摘抄
</div>
<p ng-bind-html="content"></p>
<img class="ui centered medium image" src="/images/loading.gif" ng-show="loading">
</div>
</div>
<div class="actions">
<div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div>
<button class="positive ui right button">关闭页面</button>
</div>
</div>

View File

@ -30,10 +30,9 @@
id="{{bookmark.id}}">
<img
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;"
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>
</div>
</div>
@ -66,10 +65,9 @@
id="{{bookmark.id}}">
<img
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;"
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>
</div>
</div>
@ -89,7 +87,7 @@
<tbody>
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<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;">
{{ bookmark.title }}
</span>
@ -142,7 +140,7 @@
</div>
<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;">
<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>
<!-- {{ bookmark.created_at }} -->

View File

@ -135,17 +135,15 @@
<td>
<img
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;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)"
favicon-err="./images/favicon/{{bookmark.id}}.ico"
ng-if="searchHotBookmarks">
<img
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;"
ng-click="jumpToUrl(bookmark.url, bookmark.id)"
favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}"
ng-if="!searchHotBookmarks">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
{{ bookmark.title }}

View File

@ -85,8 +85,8 @@
<tbody>
<tr ng-repeat="bookmark in bookmarksByTag" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<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;">
{{ bookmark.title }}
</span>
@ -129,8 +129,8 @@
<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-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;"
ng-click="detailBookmark(bookmark);$event.stopPropagation()" favicon-err="http://favicon.luchenqun.com/?url={{bookmark.url}}">
<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()">
<span>{{ bookmark.title}}</span>
</div>
</div>