-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog_demo.js
198 lines (172 loc) · 6.37 KB
/
blog_demo.js
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
ISDCBlogDemoModule = angular.module('isdcng.blogdemo.devtest', [ ]);
var users = {
0: {
user_id: 0,
username: 'Windas',
user_url: 'http://www.scuisdc.com',
user_avatar: './assets/placeholder.png'
},
1: {
user_id: 1,
username: 'Dfb',
user_url: 'http://www.scuisdc.com',
user_avatar: './assets/placeholder.png'
}
};
var articles = [
{
article_id: 0,
author_id: 0,
title: '苏共亡党亡国二十年祭', title_secondary: '苏共为何亡党亡国,以及我们从中得到的启示。',
summary: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
date: '96-12-08',
category: ['毛概']
},
{
article_id: 1,
author_id: 1,
title: '人脑计算机展望', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 2,
author_id: 1,
title: '人脑计算机展望2', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 3,
author_id: 1,
title: '人脑计算机展望3', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 4,
author_id: 1,
title: '人脑计算机展望4', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 5,
author_id: 1,
title: '人脑计算机展望5', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 6,
author_id: 1,
title: '人脑计算机展望6', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 7,
author_id: 1,
title: '人脑计算机展望', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 8,
author_id: 1,
title: '人脑计算机展望2', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 9,
author_id: 1,
title: '人脑计算机展望3', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 10,
author_id: 1,
title: '人脑计算机展望4', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 11,
author_id: 1,
title: '人脑计算机展望5', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
{
article_id: 12,
author_id: 1,
title: '人脑计算机展望6', title_secondary: '如何取得人脑的 root 权限?基础带你一探究竟。',
summary: 'The early chapters are organized in order of conceptual difficulty, starting',
date: '96-12-08',
category: ['基础', '人脑计算机']
},
];
ISDCBlogDemoModule.service('articlesService', function () {
var total_len = function () { return articles.length; };
var article_list = function (start, end) {
if (start === null || start < 0)
start = 0;
if (end === null || end >= total_len())
end = total_len();
var ret = [ ];
for (var i = start; i < end; i++)
ret.push(articles[i]);
return ret;
};
var predefined_article = function (article_id) {
this.article_id = article_id; };
predefined_article.prototype = {
article_id: 0,
title: '中国花了 20 年时间打基础',
content: [
{ pid: 0, content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' }
],
author_id: 0,
author_name: 'Windas',
comments: [
{
author_id: 0,
author_name: 'Windas',
content: '打基础是大事。我们要尽量打好基础(说的跟基础想打就能打似的),不过就算不行的话我们也有压力嘛。'
},
{
author_id: 0,
author_name: 'Windas',
content: '打基础是大事。我们要尽量打好基础(说的跟基础想打就能打似的),不过就算不行的话我们也有压力嘛。'
}
]
};
return {
total_len: total_len,
article_list: article_list,
// you cannot return the predefined var directly
// or it would cause an 'infdig'
article_detail: function (article_id) {
return new predefined_article(article_id); }
};
});
ISDCBlogDemoModule.service('usersService', function () {
var get_userinfo = function (id) {
return users[id]; };
return {
get_userinfo: get_userinfo
};
});