Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
b632302e
Commit
b632302e
authored
Jun 28, 2012
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #36
parent
33aa1635
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
core/src/main/java/org/b3log/solo/processor/BlogProcessor.java
...src/main/java/org/b3log/solo/processor/BlogProcessor.java
+97
-0
No files found.
core/src/main/java/org/b3log/solo/processor/BlogProcessor.java
0 → 100644
View file @
b632302e
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
processor
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.annotation.RequestProcessing
;
import
org.b3log.latke.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.repository.StatisticRepository
;
import
org.b3log.solo.repository.impl.StatisticRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.TagQueryService
;
import
org.b3log.solo.util.Articles
;
import
org.json.JSONObject
;
/**
* Blog processor.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, Jun 28, 2012
* @since 0.4.6
*/
@RequestProcessor
public
final
class
BlogProcessor
{
/**
* Article utilities.
*/
private
Articles
articleUtils
=
Articles
.
getInstance
();
/**
* Tag query service.
*/
private
TagQueryService
tagQueryService
=
TagQueryService
.
getInstance
();
/**
* Preference query service.
*/
private
PreferenceQueryService
preferenceQueryService
=
PreferenceQueryService
.
getInstance
();
/**
* Statistic repository.
*/
private
StatisticRepository
statisticRepository
=
StatisticRepositoryImpl
.
getInstance
();
/**
* Gets blog information.
*
* <ul>
* <li>Time of the recent updated article</li>
* <li>Article count</li>
* <li>Comment count</li>
* <li>Tag count</li>
* <li>Serve path</li>
* <li>Static serve path</li>
* <li>Solo version</li>
* <li>Runtime environment (GAE/LOCAL)</li>
* <li>Locale</li>
* </ul>
*
* @param context the specified context
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/blog/info"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getRecentArticleTime
(
final
HTTPRequestContext
context
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
jsonObject
.
put
(
"recentArticleTime"
,
articleUtils
.
getRecentArticleTime
());
final
JSONObject
statistic
=
statisticRepository
.
get
(
Statistic
.
STATISTIC
);
jsonObject
.
put
(
"articleCount"
,
statistic
.
getLong
(
Statistic
.
STATISTIC_PUBLISHED_ARTICLE_COUNT
));
jsonObject
.
put
(
"commentCount"
,
statistic
.
getLong
(
Statistic
.
STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
));
jsonObject
.
put
(
"tagCount"
,
tagQueryService
.
getTagCount
());
jsonObject
.
put
(
"servePath"
,
Latkes
.
getServePath
());
jsonObject
.
put
(
"staticServePath"
,
Latkes
.
getStaticServePath
());
jsonObject
.
put
(
"version"
,
SoloServletListener
.
VERSION
);
jsonObject
.
put
(
"runtimeEnv"
,
Latkes
.
getRuntimeEnv
());
jsonObject
.
put
(
"locale"
,
Latkes
.
getLocale
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment