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
06be1bc7
Commit
06be1bc7
authored
Nov 17, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复浏览计数问题
parent
512b0adc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
42 deletions
+93
-42
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
.../main/java/org/b3log/solo/processor/ArticleProcessor.java
+13
-1
core/src/main/java/org/b3log/solo/processor/IndexProcessor.java
...rc/main/java/org/b3log/solo/processor/IndexProcessor.java
+10
-1
core/src/main/java/org/b3log/solo/processor/PageProcessor.java
...src/main/java/org/b3log/solo/processor/PageProcessor.java
+11
-2
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
.../src/main/java/org/b3log/solo/processor/TagProcessor.java
+10
-1
core/src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
.../java/org/b3log/solo/processor/UserTemplateProcessor.java
+14
-5
core/src/main/java/org/b3log/solo/processor/renderer/ConsoleRenderer.java
...va/org/b3log/solo/processor/renderer/ConsoleRenderer.java
+8
-5
core/src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+27
-27
No files found.
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
06be1bc7
...
...
@@ -66,7 +66,7 @@ import org.jsoup.Jsoup;
* Article processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.2.1
3, Oct 26
, 2013
* @version 1.1.2.1
4, Nov 17
, 2013
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -130,6 +130,12 @@ public class ArticleProcessor {
*/
@Inject
private
ArticleMgmtService
articleMgmtService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Shows the article view password form.
...
...
@@ -724,6 +730,8 @@ public class ArticleProcessor {
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
@@ -817,6 +825,8 @@ public class ArticleProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
@@ -927,6 +937,8 @@ public class ArticleProcessor {
if
(!
Requests
.
hasBeenServed
(
request
,
response
))
{
articleMgmtService
.
incViewCount
(
articleId
);
}
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
06be1bc7
...
...
@@ -45,6 +45,7 @@ import org.b3log.solo.model.Preference;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONObject
;
...
...
@@ -54,7 +55,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.1.1.
4, Sep 11
, 2013
* @version 1.1.1.
5, Nov 17
, 2013
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -82,6 +83,12 @@ public class IndexProcessor {
*/
@Inject
private
LangPropsService
langPropsService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Shows index with the specified context.
...
...
@@ -126,6 +133,8 @@ public class IndexProcessor {
}
dataModel
.
put
(
Common
.
PATH
,
""
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/PageProcessor.java
View file @
06be1bc7
...
...
@@ -40,6 +40,7 @@ import org.b3log.solo.model.Preference;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.CommentQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONObject
;
...
...
@@ -49,7 +50,7 @@ import org.json.JSONObject;
* Page processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
3, Oct 14
, 2013
* @version 1.1.0.
4, Nov 17
, 2013
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -84,9 +85,15 @@ public class PageProcessor {
@Inject
private
CommentQueryService
commentQueryService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Shows page with the specified context.
*
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/page"
,
method
=
HTTPRequestMethod
.
GET
)
...
...
@@ -144,6 +151,8 @@ public class PageProcessor {
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
06be1bc7
...
...
@@ -48,6 +48,7 @@ import org.b3log.solo.model.Tag;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.service.TagQueryService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.b3log.solo.util.Skins
;
...
...
@@ -60,7 +61,7 @@ import org.json.JSONObject;
* Tag processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.
2, Oct 29
, 2013
* @version 1.1.1.
3, Nov 17
, 2013
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -107,6 +108,12 @@ public class TagProcessor {
@Inject
private
TagQueryService
tagQueryService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Shows articles related with a tag with the specified context.
*
...
...
@@ -201,6 +208,8 @@ public class TagProcessor {
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
View file @
06be1bc7
...
...
@@ -38,23 +38,24 @@ import org.b3log.latke.util.freemarker.Templates;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONObject
;
/**
* User template processor.
*
*
* <p>
* User can add a template (for example "links.ftl") then visits the page ("links.html").
* </p>
*
*
* <p>
* See <a href="https://code.google.com/p/b3log-solo/issues/detail?id=409">issue 409</a> for more details.
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Jul 11, 2012
* @version 1.0.0.
4, Nov 17, 2013
* @since 0.4.5
*/
@RequestProcessor
...
...
@@ -83,13 +84,19 @@ public class UserTemplateProcessor {
@Inject
private
LangPropsService
langPropsService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Shows the user template page.
*
*
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @throws IOException io exception
* @throws IOException io exception
*/
@RequestProcessing
(
value
=
"/*.html"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showPage
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
...
...
@@ -129,6 +136,8 @@ public class UserTemplateProcessor {
filler
.
fillUserTemplate
(
request
,
template
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/renderer/ConsoleRenderer.java
View file @
06be1bc7
...
...
@@ -28,11 +28,11 @@ import org.b3log.solo.SoloServletListener;
/**
* <a href="http://freemarker.org">FreeMarker</a> HTTP response
* <a href="http://freemarker.org">FreeMarker</a> HTTP response
* renderer for administrator console and initialization rendering.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
0, Mar 29, 2012
* @version 1.0.0.
1, Nov 17, 2013
* @since 0.4.1
*/
public
final
class
ConsoleRenderer
extends
AbstractFreeMarkerRenderer
{
...
...
@@ -60,9 +60,12 @@ public final class ConsoleRenderer extends AbstractFreeMarkerRenderer {
}
@Override
protected
Template
getTemplate
(
final
String
templateDirName
,
final
String
templateName
)
throws
IOException
{
return
TEMPLATE_CFG
.
getTemplate
(
templateName
);
protected
Template
getTemplate
(
final
String
templateDirName
,
final
String
templateName
)
{
try
{
return
TEMPLATE_CFG
.
getTemplate
(
templateName
);
}
catch
(
final
IOException
e
)
{
return
null
;
}
}
@Override
...
...
core/src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
06be1bc7
...
...
@@ -39,9 +39,9 @@ import org.json.JSONException;
/**
* Statistic management service.
*
*
* <p>
*
<b>Note</b>: The {@link #onlineVisitorCount online visitor counting} is NOT cluster-safe.
* <b>Note</b>: The {@link #onlineVisitorCount online visitor counting} is NOT cluster-safe.
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
...
...
@@ -76,7 +76,7 @@ public class StatisticMgmtService {
/**
* Online visitor cache.
*
*
* <p>
* <ip, recentTime>
* </p>
...
...
@@ -90,23 +90,21 @@ public class StatisticMgmtService {
/**
* Blog statistic view count +1.
*
*
* <p>
* If it is a search engine bot made the specified request, will NOT increment blog statistic view count.
* </p>
*
*
* <p>
* There is a cron job (/console/stat/viewcnt) to flush the blog view count from cache to datastore.
* </p>
*
*
* @param request the specified request
* @param response the specified response
* @throws RepositoryException repository exception
* @throws JSONException json exception
* @see Requests#searchEngineBotRequest(javax.servlet.http.HttpServletRequest)
* @throws ServiceException service exception
* @see Requests#searchEngineBotRequest(javax.servlet.http.HttpServletRequest)
*/
public
void
incBlogViewCount
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
RepositoryException
,
JSONException
{
public
void
incBlogViewCount
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
ServiceException
{
if
(
Requests
.
searchEngineBotRequest
(
request
))
{
return
;
}
...
...
@@ -115,22 +113,22 @@ public class StatisticMgmtService {
return
;
}
final
JSONObject
statistic
=
statisticRepository
.
get
(
Statistic
.
STATISTIC
);
if
(
null
==
statistic
)
{
return
;
}
final
Transaction
transaction
=
statisticRepository
.
beginTransaction
();
JSONObject
statistic
=
null
;
LOGGER
.
log
(
Level
.
TRACE
,
"Before inc blog view count[statistic={0}]"
,
statistic
);
try
{
statistic
=
statisticRepository
.
get
(
Statistic
.
STATISTIC
);
if
(
null
==
statistic
)
{
return
;
}
int
blogViewCnt
=
statistic
.
getInt
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
);
LOGGER
.
log
(
Level
.
TRACE
,
"Before inc blog view count[statistic={0}]"
,
statistic
);
++
blogViewCnt
;
statistic
.
put
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
,
blogViewCnt
);
int
blogViewCnt
=
statistic
.
optInt
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
);
final
Transaction
transaction
=
statisticRepository
.
beginTransaction
();
++
blogViewCnt
;
statistic
.
put
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
,
blogViewCnt
);
try
{
statisticRepository
.
update
(
Statistic
.
STATISTIC
,
statistic
);
transaction
.
commit
();
...
...
@@ -140,9 +138,11 @@ public class StatisticMgmtService {
}
LOGGER
.
log
(
Level
.
ERROR
,
"Updates blog view count failed"
,
e
);
return
;
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Inced blog view count[statistic={0}]"
,
statistic
);
LOGGER
.
log
(
Level
.
TRACE
,
"Inced blog view count[statistic={0}]"
,
statistic
);
}
/**
...
...
@@ -317,7 +317,7 @@ public class StatisticMgmtService {
/**
* Refreshes online visitor count for the specified request.
*
*
* @param request the specified request
*/
public
void
onlineVisitorCount
(
final
HttpServletRequest
request
)
{
...
...
@@ -373,7 +373,7 @@ public class StatisticMgmtService {
/**
* Sets the article repository with the specified article repository.
*
*
* @param articleRepository the specified article repository
*/
public
void
setArticleRepository
(
final
ArticleRepository
articleRepository
)
{
...
...
@@ -382,7 +382,7 @@ public class StatisticMgmtService {
/**
* Sets the statistic repository with the specified statistic repository.
*
*
* @param statisticRepository the specified statistic repository
*/
public
void
setStatisticRepository
(
final
StatisticRepository
statisticRepository
)
{
...
...
@@ -391,7 +391,7 @@ public class StatisticMgmtService {
/**
* Sets the language service with the specified language service.
*
*
* @param langPropsService the specified language service
*/
public
void
setLangPropsService
(
final
LangPropsService
langPropsService
)
{
...
...
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