forked from cevio/PJBlog4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.asp
More file actions
151 lines (134 loc) · 4.38 KB
/
default.asp
File metadata and controls
151 lines (134 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!--#include file="config.asp" -->
<%
// '加载用户登入状态
require("status");
// '加载全局变量模块
pageCustomParams.tempCaches.globalCache = require("cache_global");
// '加载fn模块
pageCustomParams.tempModules.fns = require("fn");
// '获取页面page参数
pageCustomParams.page = http.get("page");
// 'Page参数的逻辑判断和过滤
if ( pageCustomParams.page.length === 0 ){
pageCustomParams.page = 1;
}else{
// '判断是否是数字类型(包括字符串)
if ( !isNaN( pageCustomParams.page ) ){
// '统一转成数字类型
pageCustomParams.page = Number(pageCustomParams.page);
if ( pageCustomParams.page < 1 ){
pageCustomParams.page = 1;
}
}else{
console.end("page params error.");
}
};
// '当前页面分类参数(进入category筛选模式)
pageCustomParams.cateID = http.get("c");
if ( pageCustomParams.cateID.length === 0 ){
pageCustomParams.cateID = 0;
}else{
if ( !isNaN(pageCustomParams.cateID) ){
pageCustomParams.cateID = Number(pageCustomParams.cateID);
if ( pageCustomParams.cateID < 1 ){
pageCustomParams.cateID = 0;
}
}else{
pageCustomParams.cateID = 0;
}
};
pageCustomParams.article = {
list: [],
pagebar: []
};
// '处理日志列表
;(function(){
var cache = require("cache"),
tagsCacheData = require("tags"),
fns = require("fn"),
perPage = pageCustomParams.tempCaches.globalCache.articleperpagecount,
categoryCacheData = cache.load("category"),
articleCurrentPage = pageCustomParams.page,
modules,
articlesArray = [],
categoryJSON = categoryCacheData.list,
categoryArray = categoryCacheData.arrays,
i = 0;
function getTags( tagStr ){
var tagStrArrays = tagsCacheData.reFormatTags(tagStr),
keeper = [];
for ( var j = 0 ; j < tagStrArrays.length ; j++ ){
var rets = tagsCacheData.readTagFromCache( Number(tagStrArrays[j]) );
if ( rets !== undefined ){
keeper.push({
id: Number(tagStrArrays[j]),
name: rets.name,
url: "tags.asp?id=" + tagStrArrays[j],
count: rets.count
});
}
}
return keeper;
}
function getCategoryName( id ){
var rets = {};
if ( categoryJSON[id + ""] !== undefined ){
rets.id = id;
rets.name = categoryJSON[id + ""].name;
rets.info = categoryJSON[id + ""].info;
rets.icon = "profile/icons/" + categoryJSON[id + ""].icon;
rets.url = "default.asp?c=" + id;
}
return rets;
}
if ( pageCustomParams.cateID === undefined || pageCustomParams.cateID === 0 ){
modules = cache.load("article_pages");
}else{
modules = cache.load("article_pages_cate", pageCustomParams.cateID);
}
categoryArray = categoryArray.sort(function( A, B ){
return A.order > B.order;
});
pageCustomParams.categorys = categoryArray;
if ( modules.length > 0 ){
var articleContainerParams = pageCustomParams.tempModules.fns.pageFormTo( articleCurrentPage, perPage, modules.length );
for ( i = articleContainerParams.from ; i <= articleContainerParams.to ; i++ ){
var articleCacheDatas = cache.load("article", Number(modules[i][0]));
articlesArray.push({
id: Number(modules[i][0]),
title: articleCacheDatas[0][0],
postDate: articleCacheDatas[0][5],
editDate: articleCacheDatas[0][6],
category: getCategoryName(articleCacheDatas[0][1]),
tags: getTags(articleCacheDatas[0][3]),
content: articleCacheDatas[0][7],
url: "article.asp?id=" + modules[i][0]
});
}
pageCustomParams.article.list = articlesArray;
var articlePagebar = pageCustomParams.tempModules.fns.pageAnalyze(articleCurrentPage, Math.ceil(modules.length / perPage));
if ( (pageCustomParams.article.list.length > 0) && ( (articlePagebar.to - articlePagebar.from) > 0 ) ){
for ( i = articlePagebar.from ; i <= articlePagebar.to ; i++ ){
var url = pageCustomParams.cateID > 0 ?
"default.asp?c=" + pageCustomParams.cateID + "&page=" + i :
"default.asp?page=" + i;
if ( articlePagebar.current === i ){
pageCustomParams.article.pagebar.push({
key: n
});
}else{
pageCustomParams.article.pagebar.push({
key: n,
url : url
});
}
}
}
}
})();
delete pageCustomParams.tempCaches;
delete pageCustomParams.tempModules;
delete pageCustomParams.tempParams;
include("profile/themes/" + pageCustomParams.global.theme + "/default.asp");
CloseConnect();
%>