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
31a5d8b5
Commit
31a5d8b5
authored
Oct 13, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#318
parent
6db5b6e3
Changes
58
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
100 additions
and
1730 deletions
+100
-1730
core/src/main/java/org/b3log/solo/SoloServletListener.java
core/src/main/java/org/b3log/solo/SoloServletListener.java
+0
-16
core/src/main/java/org/b3log/solo/event/cache/RemoveCacheListener.java
.../java/org/b3log/solo/event/cache/RemoveCacheListener.java
+0
-73
core/src/main/java/org/b3log/solo/event/plugin/PluginRefresher.java
...ain/java/org/b3log/solo/event/plugin/PluginRefresher.java
+0
-1
core/src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
.../main/java/org/b3log/solo/event/rhythm/ArticleSender.java
+5
-5
core/src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
...main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
+5
-5
core/src/main/java/org/b3log/solo/filter/InitCheckFilter.java
.../src/main/java/org/b3log/solo/filter/InitCheckFilter.java
+25
-32
core/src/main/java/org/b3log/solo/filter/PageCacheFilter.java
.../src/main/java/org/b3log/solo/filter/PageCacheFilter.java
+0
-218
core/src/main/java/org/b3log/solo/filter/PermalinkFilter.java
.../src/main/java/org/b3log/solo/filter/PermalinkFilter.java
+12
-2
core/src/main/java/org/b3log/solo/model/Cache.java
core/src/main/java/org/b3log/solo/model/Cache.java
+0
-61
core/src/main/java/org/b3log/solo/model/Common.java
core/src/main/java/org/b3log/solo/model/Common.java
+1
-11
core/src/main/java/org/b3log/solo/model/Preference.java
core/src/main/java/org/b3log/solo/model/Preference.java
+0
-18
core/src/main/java/org/b3log/solo/plugin/cache/AdminCacheService.java
...n/java/org/b3log/solo/plugin/cache/AdminCacheService.java
+0
-307
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
.../main/java/org/b3log/solo/processor/ArticleProcessor.java
+7
-35
core/src/main/java/org/b3log/solo/processor/CacheProcessor.java
...rc/main/java/org/b3log/solo/processor/CacheProcessor.java
+0
-127
core/src/main/java/org/b3log/solo/processor/ErrorProcessor.java
...rc/main/java/org/b3log/solo/processor/ErrorProcessor.java
+1
-1
core/src/main/java/org/b3log/solo/processor/IndexProcessor.java
...rc/main/java/org/b3log/solo/processor/IndexProcessor.java
+3
-22
core/src/main/java/org/b3log/solo/processor/PageProcessor.java
...src/main/java/org/b3log/solo/processor/PageProcessor.java
+3
-12
core/src/main/java/org/b3log/solo/processor/RepairProcessor.java
...c/main/java/org/b3log/solo/processor/RepairProcessor.java
+0
-11
core/src/main/java/org/b3log/solo/processor/SitemapProcessor.java
.../main/java/org/b3log/solo/processor/SitemapProcessor.java
+1
-5
core/src/main/java/org/b3log/solo/processor/StatProcessor.java
...src/main/java/org/b3log/solo/processor/StatProcessor.java
+1
-21
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
.../src/main/java/org/b3log/solo/processor/TagProcessor.java
+5
-26
core/src/main/java/org/b3log/solo/processor/UpgradeProcessor.java
.../main/java/org/b3log/solo/processor/UpgradeProcessor.java
+0
-3
core/src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
.../java/org/b3log/solo/processor/UserTemplateProcessor.java
+3
-11
core/src/main/java/org/b3log/solo/processor/renderer/FrontRenderer.java
...java/org/b3log/solo/processor/renderer/FrontRenderer.java
+0
-133
core/src/main/java/org/b3log/solo/processor/util/Filler.java
core/src/main/java/org/b3log/solo/processor/util/Filler.java
+14
-1
core/src/main/java/org/b3log/solo/processor/util/TopBars.java
.../src/main/java/org/b3log/solo/processor/util/TopBars.java
+0
-2
core/src/main/java/org/b3log/solo/repository/impl/CommentRepositoryImpl.java
...org/b3log/solo/repository/impl/CommentRepositoryImpl.java
+0
-22
core/src/main/java/org/b3log/solo/repository/impl/StatisticRepositoryImpl.java
...g/b3log/solo/repository/impl/StatisticRepositoryImpl.java
+0
-13
core/src/main/java/org/b3log/solo/service/ArticleMgmtService.java
.../main/java/org/b3log/solo/service/ArticleMgmtService.java
+0
-1
core/src/main/java/org/b3log/solo/service/InitService.java
core/src/main/java/org/b3log/solo/service/InitService.java
+0
-7
core/src/main/java/org/b3log/solo/service/PermalinkQueryService.java
...in/java/org/b3log/solo/service/PermalinkQueryService.java
+1
-1
core/src/main/java/org/b3log/solo/service/PluginMgmtService.java
...c/main/java/org/b3log/solo/service/PluginMgmtService.java
+0
-5
core/src/main/java/org/b3log/solo/service/PluginQueryService.java
.../main/java/org/b3log/solo/service/PluginQueryService.java
+1
-1
core/src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
...in/java/org/b3log/solo/service/PreferenceMgmtService.java
+0
-49
core/src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+9
-131
core/src/test/resources/latke.properties
core/src/test/resources/latke.properties
+0
-4
war/bae/src/main/resources/latke.properties
war/bae/src/main/resources/latke.properties
+0
-4
war/gae/src/main/resources/latke.properties
war/gae/src/main/resources/latke.properties
+0
-4
war/h2/src/main/resources/latke.properties
war/h2/src/main/resources/latke.properties
+0
-4
war/mysql/src/main/resources/latke.properties
war/mysql/src/main/resources/latke.properties
+0
-4
war/src/main/resources/lang_en_US.properties
war/src/main/resources/lang_en_US.properties
+0
-2
war/src/main/resources/lang_zh_CN.properties
war/src/main/resources/lang_zh_CN.properties
+0
-2
war/src/main/webapp/WEB-INF/cron.xml
war/src/main/webapp/WEB-INF/cron.xml
+0
-6
war/src/main/webapp/WEB-INF/web.xml
war/src/main/webapp/WEB-INF/web.xml
+0
-8
war/src/main/webapp/js/admin/latkeAdmin.js
war/src/main/webapp/js/admin/latkeAdmin.js
+1
-1
war/src/main/webapp/js/admin/latkeAdmin.min.js
war/src/main/webapp/js/admin/latkeAdmin.min.js
+1
-1
war/src/main/webapp/js/common.js
war/src/main/webapp/js/common.js
+0
-22
war/src/main/webapp/js/common.min.js
war/src/main/webapp/js/common.min.js
+1
-1
war/src/main/webapp/plugins/admin-cache/lang_en_US.properties
...src/main/webapp/plugins/admin-cache/lang_en_US.properties
+0
-33
war/src/main/webapp/plugins/admin-cache/lang_zh_CN.properties
...src/main/webapp/plugins/admin-cache/lang_zh_CN.properties
+0
-33
war/src/main/webapp/plugins/admin-cache/plugin.ftl
war/src/main/webapp/plugins/admin-cache/plugin.ftl
+0
-162
war/src/main/webapp/plugins/admin-cache/plugin.properties
war/src/main/webapp/plugins/admin-cache/plugin.properties
+0
-32
war/src/main/webapp/skins/ease/footer.ftl
war/src/main/webapp/skins/ease/footer.ftl
+0
-2
war/src/main/webapp/skins/ease/lang/lang_en_US.properties
war/src/main/webapp/skins/ease/lang/lang_en_US.properties
+0
-2
war/src/main/webapp/skins/ease/lang/lang_zh_CN.properties
war/src/main/webapp/skins/ease/lang/lang_zh_CN.properties
+0
-2
war/src/main/webapp/skins/mobile/lang/lang_en_US.properties
war/src/main/webapp/skins/mobile/lang/lang_en_US.properties
+0
-2
war/src/main/webapp/skins/mobile/lang/lang_zh_CN.properties
war/src/main/webapp/skins/mobile/lang/lang_zh_CN.properties
+0
-2
war/src/main/webapp/top-bar.ftl
war/src/main/webapp/top-bar.ftl
+0
-8
No files found.
core/src/main/java/org/b3log/solo/SoloServletListener.java
View file @
31a5d8b5
...
@@ -35,8 +35,6 @@ import org.b3log.latke.servlet.AbstractServletListener;
...
@@ -35,8 +35,6 @@ import org.b3log.latke.servlet.AbstractServletListener;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.solo.event.cache.RemoveCacheListener
;
import
org.b3log.solo.event.comment.ArticleCommentReplyNotifier
;
import
org.b3log.solo.event.comment.ArticleCommentReplyNotifier
;
import
org.b3log.solo.event.comment.PageCommentReplyNotifier
;
import
org.b3log.solo.event.comment.PageCommentReplyNotifier
;
import
org.b3log.solo.event.ping.AddArticleGoogleBlogSearchPinger
;
import
org.b3log.solo.event.ping.AddArticleGoogleBlogSearchPinger
;
...
@@ -121,8 +119,6 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -121,8 +119,6 @@ public final class SoloServletListener extends AbstractServletListener {
final
Transaction
transaction
=
preferenceRepository
.
beginTransaction
();
final
Transaction
transaction
=
preferenceRepository
.
beginTransaction
();
// Cache will be cleared manaully if necessary, see loadPreference.
transaction
.
clearQueryCache
(
false
);
try
{
try
{
loadPreference
();
loadPreference
();
...
@@ -201,12 +197,6 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -201,12 +197,6 @@ public final class SoloServletListener extends AbstractServletListener {
*
*
* <p>
* <p>
* Loads preference from repository, loads skins from skin directory then sets it into preference if the skins changed.
* Loads preference from repository, loads skins from skin directory then sets it into preference if the skins changed.
* Puts preference into cache and persists it to repository finally.
* </p>
*
* <p>
* <b>Note</b>: Do NOT use method {@link org.b3log.solo.service.PreferenceQueryService#getPreference() } to load it, caused by the
* method may retrieve it from cache.
* </p>
* </p>
*/
*/
private
void
loadPreference
()
{
private
void
loadPreference
()
{
...
@@ -227,10 +217,6 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -227,10 +217,6 @@ public final class SoloServletListener extends AbstractServletListener {
final
PreferenceMgmtService
preferenceMgmtService
=
beanManager
.
getReference
(
PreferenceMgmtService
.
class
);
final
PreferenceMgmtService
preferenceMgmtService
=
beanManager
.
getReference
(
PreferenceMgmtService
.
class
);
preferenceMgmtService
.
loadSkins
(
preference
);
preferenceMgmtService
.
loadSkins
(
preference
);
final
boolean
pageCacheEnabled
=
preference
.
getBoolean
(
Preference
.
PAGE_CACHE_ENABLED
);
Templates
.
enableCache
(
pageCacheEnabled
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
@@ -263,8 +249,6 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -263,8 +249,6 @@ public final class SoloServletListener extends AbstractServletListener {
eventManager
.
registerListener
(
new
ArticleSender
());
eventManager
.
registerListener
(
new
ArticleSender
());
eventManager
.
registerListener
(
new
ArticleUpdater
());
eventManager
.
registerListener
(
new
ArticleUpdater
());
eventManager
.
registerListener
(
new
CommentSender
());
eventManager
.
registerListener
(
new
CommentSender
());
// Cache
eventManager
.
registerListener
(
new
RemoveCacheListener
());
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Register event processors error"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Register event processors error"
,
e
);
throw
new
IllegalStateException
(
e
);
throw
new
IllegalStateException
(
e
);
...
...
core/src/main/java/org/b3log/solo/event/cache/RemoveCacheListener.java
deleted
100644 → 0
View file @
6db5b6e3
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 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
.
event
.
cache
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.Event
;
import
org.b3log.latke.event.EventException
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.solo.service.StatisticMgmtService
;
/**
* This listener is responsible for handling remove cache event.
*
* <p>
* Flush the statistic to repository.
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Nov 28, 2011
* @since 0.3.1
*/
public
final
class
RemoveCacheListener
extends
AbstractEventListener
<
Void
>
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
RemoveCacheListener
.
class
.
getName
());
@Override
public
void
action
(
final
Event
<
Void
>
event
)
throws
EventException
{
LOGGER
.
log
(
Level
.
DEBUG
,
"Processing an event[type={0} in listener[className={2}]"
,
new
Object
[]
{
event
.
getType
(),
RemoveCacheListener
.
class
.
getName
()});
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
StatisticMgmtService
statisticMgmtService
=
beanManager
.
getReference
(
StatisticMgmtService
.
class
);
try
{
statisticMgmtService
.
flushStatistic
();
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Flushes statistic to repository failed"
,
e
);
}
}
/**
* Gets the event type {@linkplain PageCaches#REMOVE_CACHE}.
*
* @return event type
*/
@Override
public
String
getEventType
()
{
return
PageCaches
.
REMOVE_CACHE
;
}
}
core/src/main/java/org/b3log/solo/event/plugin/PluginRefresher.java
View file @
31a5d8b5
...
@@ -58,7 +58,6 @@ public final class PluginRefresher extends AbstractEventListener<List<AbstractPl
...
@@ -58,7 +58,6 @@ public final class PluginRefresher extends AbstractEventListener<List<AbstractPl
final
Transaction
transaction
=
pluginRepository
.
beginTransaction
();
final
Transaction
transaction
=
pluginRepository
.
beginTransaction
();
transaction
.
clearQueryCache
(
false
);
try
{
try
{
final
PluginMgmtService
pluginMgmtService
=
beanManager
.
getReference
(
PluginMgmtService
.
class
);
final
PluginMgmtService
pluginMgmtService
=
beanManager
.
getReference
(
PluginMgmtService
.
class
);
...
...
core/src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
View file @
31a5d8b5
...
@@ -103,11 +103,11 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
...
@@ -103,11 +103,11 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
throw
new
EventException
(
"Not found preference"
);
throw
new
EventException
(
"Not found preference"
);
}
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
//
if (Latkes.getServePath().contains("localhost")) {
LOGGER
.
log
(
Level
.
INFO
,
"Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm"
,
//
LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
new
Object
[]
{
originalArticle
.
getString
(
Keys
.
OBJECT_ID
),
originalArticle
.
getString
(
Article
.
ARTICLE_TITLE
)});
//
new Object[] {originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
return
;
//
return;
}
//
}
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
...
...
core/src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
View file @
31a5d8b5
...
@@ -102,11 +102,11 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
...
@@ -102,11 +102,11 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
throw
new
EventException
(
"Not found preference"
);
throw
new
EventException
(
"Not found preference"
);
}
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
//
if (Latkes.getServePath().contains("localhost")) {
LOGGER
.
log
(
Level
.
INFO
,
"Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm"
,
//
LOGGER.log(Level.INFO, "Blog Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
new
Object
[]
{
originalArticle
.
getString
(
Keys
.
OBJECT_ID
),
originalArticle
.
getString
(
Article
.
ARTICLE_TITLE
)});
//
new Object[] {originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE)});
return
;
//
return;
}
//
}
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
...
...
core/src/main/java/org/b3log/solo/filter/InitCheckFilter.java
View file @
31a5d8b5
...
@@ -31,13 +31,12 @@ import org.b3log.latke.ioc.LatkeBeanManager;
...
@@ -31,13 +31,12 @@ import org.b3log.latke.ioc.LatkeBeanManager;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.serv
ice.ServiceException
;
import
org.b3log.latke.serv
let.DispatcherServlet
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestDispatcher
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HttpControl
;
import
org.b3log.latke.servlet.renderer.HTTP500Renderer
;
import
org.b3log.solo.service.InitService
;
import
org.b3log.solo.service.InitService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
/**
/**
...
@@ -84,7 +83,6 @@ public final class InitCheckFilter implements Filter {
...
@@ -84,7 +83,6 @@ public final class InitCheckFilter implements Filter {
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
InitService
initService
=
beanManager
.
getReference
(
InitService
.
class
);
final
InitService
initService
=
beanManager
.
getReference
(
InitService
.
class
);
try
{
if
(
initService
.
isInited
())
{
if
(
initService
.
isInited
())
{
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
...
@@ -98,12 +96,6 @@ public final class InitCheckFilter implements Filter {
...
@@ -98,12 +96,6 @@ public final class InitCheckFilter implements Filter {
return
;
return
;
}
}
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
LOGGER
.
debug
(
"Try to get preference to confirm whether the preference exixts"
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
)
{
LOGGER
.
log
(
Level
.
WARN
,
"B3log Solo has not been initialized, so redirects to /init"
);
LOGGER
.
log
(
Level
.
WARN
,
"B3log Solo has not been initialized, so redirects to /init"
);
final
HTTPRequestContext
context
=
new
HTTPRequestContext
();
final
HTTPRequestContext
context
=
new
HTTPRequestContext
();
...
@@ -114,14 +106,15 @@ public final class InitCheckFilter implements Filter {
...
@@ -114,14 +106,15 @@ public final class InitCheckFilter implements Filter {
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_URI
,
Latkes
.
getContextPath
()
+
"/init"
);
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_URI
,
Latkes
.
getContextPath
()
+
"/init"
);
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_METHOD
,
HTTPRequestMethod
.
GET
.
name
());
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_METHOD
,
HTTPRequestMethod
.
GET
.
name
());
HTTPRequestDispatcher
.
dispatch
(
context
);
final
HttpControl
httpControl
=
new
HttpControl
(
DispatcherServlet
.
SYS_HANDLER
.
iterator
(),
context
);
}
else
{
// XXX: Wrong state of SoloServletListener.isInited()
try
{
chain
.
doFilter
(
request
,
response
);
httpControl
.
nextHandler
();
}
}
catch
(
final
Exception
e
)
{
}
catch
(
final
ServiceException
e
)
{
context
.
setRenderer
(
new
HTTP500Renderer
(
e
));
((
HttpServletResponse
)
response
).
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
}
}
DispatcherServlet
.
result
(
context
);
}
}
@Override
@Override
...
...
core/src/main/java/org/b3log/solo/filter/PageCacheFilter.java
deleted
100644 → 0
View file @
6db5b6e3
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 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
.
filter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
javax.servlet.Filter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.FilterConfig
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsServiceImpl
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.util.StaticResources
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.processor.util.TopBars
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.impl.ArticleRepositoryImpl
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Page cache filter.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.1, Jan 8, 2013
* @since 0.3.1
*/
public
final
class
PageCacheFilter
implements
Filter
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
PageCacheFilter
.
class
.
getName
());
@Override
public
void
init
(
final
FilterConfig
filterConfig
)
throws
ServletException
{}
/**
* Try to write response from cache.
*
* @param request the specified request
* @param response the specified response
* @param chain filter chain
* @throws IOException io exception
* @throws ServletException servlet exception
*/
@Override
public
void
doFilter
(
final
ServletRequest
request
,
final
ServletResponse
response
,
final
FilterChain
chain
)
throws
IOException
,
ServletException
{
final
long
startTimeMillis
=
System
.
currentTimeMillis
();
request
.
setAttribute
(
Keys
.
HttpRequest
.
START_TIME_MILLIS
,
startTimeMillis
);
final
HttpServletRequest
httpServletRequest
=
(
HttpServletRequest
)
request
;
final
String
requestURI
=
httpServletRequest
.
getRequestURI
();
LOGGER
.
log
(
Level
.
DEBUG
,
"Request URI[{0}]"
,
requestURI
);
if
(
StaticResources
.
isStatic
(
httpServletRequest
))
{
final
String
path
=
httpServletRequest
.
getServletPath
()
+
httpServletRequest
.
getPathInfo
();
LOGGER
.
log
(
Level
.
TRACE
,
"Requests a static resource, forwards to servlet[path={0}]"
,
path
);
request
.
getRequestDispatcher
(
path
).
forward
(
request
,
response
);
return
;
}
if
(!
Latkes
.
isPageCacheEnabled
())
{
LOGGER
.
log
(
Level
.
TRACE
,
"Page cache is disabled"
);
chain
.
doFilter
(
request
,
response
);
return
;
}
final
String
skinDirName
=
(
String
)
httpServletRequest
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
);
if
(
"mobile"
.
equals
(
skinDirName
))
{
// Mobile request, bypasses page caching
chain
.
doFilter
(
request
,
response
);
return
;
}
String
pageCacheKey
;
final
String
queryString
=
httpServletRequest
.
getQueryString
();
pageCacheKey
=
(
String
)
request
.
getAttribute
(
Keys
.
PAGE_CACHE_KEY
);
if
(
Strings
.
isEmptyOrNull
(
pageCacheKey
))
{
pageCacheKey
=
PageCaches
.
getPageCacheKey
(
requestURI
,
queryString
);
request
.
setAttribute
(
Keys
.
PAGE_CACHE_KEY
,
pageCacheKey
);
}
final
JSONObject
cachedPageContentObject
=
PageCaches
.
get
(
pageCacheKey
,
httpServletRequest
,
(
HttpServletResponse
)
response
);
if
(
null
==
cachedPageContentObject
)
{
LOGGER
.
log
(
Level
.
DEBUG
,
"Page cache miss for request URI[{0}]"
,
requestURI
);
chain
.
doFilter
(
request
,
response
);
return
;
}
final
String
cachedType
=
cachedPageContentObject
.
optString
(
PageCaches
.
CACHED_TYPE
);
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
ArticleQueryService
articleQueryService
=
beanManager
.
getReference
(
ArticleQueryService
.
class
);
final
LangPropsService
langPropsService
=
beanManager
.
getReference
(
LangPropsServiceImpl
.
class
);
try
{
// If cached an article that has view password, dispatches the password form
if
(
langPropsService
.
get
(
PageTypes
.
ARTICLE
.
getLangeLabel
()).
equals
(
cachedType
)
&&
cachedPageContentObject
.
has
(
PageCaches
.
CACHED_PWD
))
{
JSONObject
article
=
new
JSONObject
();
final
String
articleId
=
cachedPageContentObject
.
optString
(
PageCaches
.
CACHED_OID
);
article
.
put
(
Keys
.
OBJECT_ID
,
articleId
);
article
.
put
(
Article
.
ARTICLE_VIEW_PWD
,
cachedPageContentObject
.
optString
(
PageCaches
.
CACHED_PWD
));
if
(
articleQueryService
.
needViewPwd
(
httpServletRequest
,
article
))
{
final
ArticleRepository
articleRepository
=
beanManager
.
getReference
(
ArticleRepositoryImpl
.
class
);
article
=
articleRepository
.
get
(
articleId
);
// Loads the article entity
final
HttpServletResponse
httpServletResponse
=
(
HttpServletResponse
)
response
;
try
{
httpServletResponse
.
sendRedirect
(
Latkes
.
getServePath
()
+
"/console/article-pwd?articleId="
+
article
.
optString
(
Keys
.
OBJECT_ID
));
return
;
}
catch
(
final
Exception
e
)
{
httpServletResponse
.
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
return
;
}
}
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
chain
.
doFilter
(
request
,
response
);
}
try
{
LOGGER
.
log
(
Level
.
TRACE
,
"Writes resposne for page[pageCacheKey={0}] from cache"
,
pageCacheKey
);
response
.
setContentType
(
"text/html"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
final
PrintWriter
writer
=
response
.
getWriter
();
String
cachedPageContent
=
cachedPageContentObject
.
getString
(
PageCaches
.
CACHED_CONTENT
);
final
TopBars
topbars
=
beanManager
.
getReference
(
TopBars
.
class
);
final
String
topBarHTML
=
topbars
.
getTopBarHTML
((
HttpServletRequest
)
request
,
(
HttpServletResponse
)
response
);
cachedPageContent
=
cachedPageContent
.
replace
(
Common
.
TOP_BAR_REPLACEMENT_FLAG
,
topBarHTML
);
final
String
cachedTitle
=
cachedPageContentObject
.
getString
(
PageCaches
.
CACHED_TITLE
);
LOGGER
.
log
(
Level
.
TRACE
,
"Cached value[key={0}, type={1}, title={2}]"
,
new
Object
[]
{
pageCacheKey
,
cachedType
,
cachedTitle
});
final
StatisticMgmtService
statisticMgmtService
=
beanManager
.
getReference
(
StatisticMgmtService
.
class
);
statisticMgmtService
.
incBlogViewCount
((
HttpServletRequest
)
request
,
(
HttpServletResponse
)
response
);
final
long
endimeMillis
=
System
.
currentTimeMillis
();
final
String
dateString
=
DateFormatUtils
.
format
(
endimeMillis
,
"yyyy/MM/dd HH:mm:ss"
);
final
String
msg
=
String
.
format
(
"<!-- Cached by B3log Solo(%1$d ms), %2$s -->"
,
endimeMillis
-
startTimeMillis
,
dateString
);
LOGGER
.
debug
(
msg
);
cachedPageContent
+=
Strings
.
LINE_SEPARATOR
+
msg
;
writer
.
write
(
cachedPageContent
);
writer
.
flush
();
writer
.
close
();
}
catch
(
final
JSONException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
final
RepositoryException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
chain
.
doFilter
(
request
,
response
);
}
}
@Override
public
void
destroy
()
{}
}
core/src/main/java/org/b3log/solo/filter/PermalinkFilter.java
View file @
31a5d8b5
...
@@ -33,9 +33,11 @@ import org.b3log.latke.ioc.Lifecycle;
...
@@ -33,9 +33,11 @@ import org.b3log.latke.ioc.Lifecycle;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.servlet.DispatcherServlet
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestDispatcher
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HttpControl
;
import
org.b3log.latke.servlet.renderer.HTTP500Renderer
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
...
@@ -173,7 +175,15 @@ public final class PermalinkFilter implements Filter {
...
@@ -173,7 +175,15 @@ public final class PermalinkFilter implements Filter {
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_METHOD
,
HTTPRequestMethod
.
GET
.
name
());
request
.
setAttribute
(
Keys
.
HttpRequest
.
REQUEST_METHOD
,
HTTPRequestMethod
.
GET
.
name
());
HTTPRequestDispatcher
.
dispatch
(
context
);
final
HttpControl
httpControl
=
new
HttpControl
(
DispatcherServlet
.
SYS_HANDLER
.
iterator
(),
context
);
try
{
httpControl
.
nextHandler
();
}
catch
(
final
Exception
e
)
{
context
.
setRenderer
(
new
HTTP500Renderer
(
e
));
}
DispatcherServlet
.
result
(
context
);
}
}
@Override
@Override
...
...
core/src/main/java/org/b3log/solo/model/Cache.java
deleted
100644 → 0
View file @
6db5b6e3
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 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
.
model
;
/**
* This class defines all cache model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Dec 27, 2010
*/
public
final
class
Cache
{
/**
* Cache.
*/
public
static
final
String
CACHE
=
"cache"
;
/**
* Cached count.
*/
public
static
final
String
CACHE_CACHED_COUNT
=
"cacheCachedCount"
;
/**
* Cache hit count.
*/
public
static
final
String
CACHE_HIT_COUNT
=
"cacheHitCount"
;
/**
* Cache hit bytes.
*/
public
static
final
String
CACHE_HIT_BYTES
=
"cacheHitBytes"
;
/**
* Cached bytes.
*/
public
static
final
String
CACHE_CACHED_BYTES
=
"cacheCachedBytes"
;
/**
* Cache miss count.
*/
public
static
final
String
CACHE_MISS_COUNT
=
"cacheMissCount"
;
/**
* Private default constructor.
*/
private
Cache
()
{}
}
core/src/main/java/org/b3log/solo/model/Common.java
View file @
31a5d8b5
...
@@ -221,11 +221,6 @@ public final class Common {
...
@@ -221,11 +221,6 @@ public final class Common {
*/
*/
public
static
final
String
POST_TO_COMMUNITY
=
"postToCommunity"
;
public
static
final
String
POST_TO_COMMUNITY
=
"postToCommunity"
;
/**
* Key of page cached count.
*/
public
static
final
String
PAGE_CACHED_CNT
=
"pageCachedCnt"
;
/**
/**
* Key of mini postfix.
* Key of mini postfix.
*/
*/
...
@@ -269,12 +264,7 @@ public final class Common {
...
@@ -269,12 +264,7 @@ public final class Common {
/**
/**
* Key of top bar replacement flag.
* Key of top bar replacement flag.
*/
*/
public
static
final
String
TOP_BAR_REPLACEMENT_FLAG_KEY
=
"topBarReplacement"
;
public
static
final
String
TOP_BAR
=
"topBarReplacement"
;
/**
* Top bar replacement flag.
*/
public
static
final
String
TOP_BAR_REPLACEMENT_FLAG
=
"#B3logSolo#topBarReplacement#B3logSolo#"
;
/**
/**
* Key of unused tags.
* Key of unused tags.
...
...
core/src/main/java/org/b3log/solo/model/Preference.java
View file @
31a5d8b5
...
@@ -17,8 +17,6 @@ package org.b3log.solo.model;
...
@@ -17,8 +17,6 @@ package org.b3log.solo.model;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -149,11 +147,6 @@ public final class Preference {
...
@@ -149,11 +147,6 @@ public final class Preference {
*/
*/
public
static
final
String
KEY_OF_SOLO
=
"keyOfSolo"
;
public
static
final
String
KEY_OF_SOLO
=
"keyOfSolo"
;
/**
* Key of page cache enabled.
*/
public
static
final
String
PAGE_CACHE_ENABLED
=
"pageCacheEnabled"
;
/**
/**
* Key of allow visit draft via permalink.
* Key of allow visit draft via permalink.
*/
*/
...
@@ -345,11 +338,6 @@ public final class Preference {
...
@@ -345,11 +338,6 @@ public final class Preference {
*/
*/
public
static
final
String
DEFAULT_SIGNS
;
public
static
final
String
DEFAULT_SIGNS
;
/**
* Default page cache enabled.
*/
public
static
final
boolean
DEFAULT_PAGE_CACHE_ENABLED
;
/**
/**
* Default allow visit draft via permalink.
* Default allow visit draft via permalink.
*/
*/
...
@@ -422,12 +410,6 @@ public final class Preference {
...
@@ -422,12 +410,6 @@ public final class Preference {
"Your comment on post[<a href='${postLink}'>"
+
"${postTitle}</a>] received an reply: <p>${replier}"
"Your comment on post[<a href='${postLink}'>"
+
"${postTitle}</a>] received an reply: <p>${replier}"
+
": <span><a href='${replyURL}'>${replyContent}</a></span></p>"
);
+
": <span><a href='${replyURL}'>${replyContent}</a></span></p>"
);
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
=
replyNotificationTemplate
.
toString
();
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
=
replyNotificationTemplate
.
toString
();
if
(
RuntimeEnv
.
BAE
==
Latkes
.
getRuntimeEnv
())
{
DEFAULT_PAGE_CACHE_ENABLED
=
false
;
// https://github.com/b3log/b3log-solo/issues/73
}
else
{
DEFAULT_PAGE_CACHE_ENABLED
=
true
;
}
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Creates sign error!"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Creates sign error!"
,
e
);
throw
new
IllegalStateException
(
e
);
throw
new
IllegalStateException
(
e
);
...
...
core/src/main/java/org/b3log/solo/plugin/cache/AdminCacheService.java
deleted
100644 → 0
View file @
6db5b6e3
This diff is collapsed.
Click to expand it.
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
31a5d8b5
...
@@ -28,7 +28,6 @@ import org.apache.commons.lang.StringUtils;
...
@@ -28,7 +28,6 @@ import org.apache.commons.lang.StringUtils;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.Pagination
;
import
org.b3log.latke.model.Pagination
;
...
@@ -43,6 +42,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
...
@@ -43,6 +42,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.latke.servlet.renderer.TextHTMLRenderer
;
import
org.b3log.latke.servlet.renderer.TextHTMLRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Dates
;
import
org.b3log.latke.util.Dates
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Paginator
;
import
org.b3log.latke.util.Paginator
;
...
@@ -52,7 +52,6 @@ import org.b3log.latke.util.Strings;
...
@@ -52,7 +52,6 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.renderer.FrontRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Skins
;
...
@@ -647,7 +646,7 @@ public class ArticleProcessor {
...
@@ -647,7 +646,7 @@ public class ArticleProcessor {
@RequestProcessing
(
value
=
"/authors/**"
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
"/authors/**"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showAuthorArticles
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
public
void
showAuthorArticles
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
IOException
,
JSONException
{
throws
IOException
,
JSONException
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -696,13 +695,6 @@ public class ArticleProcessor {
...
@@ -696,13 +695,6 @@ public class ArticleProcessor {
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
AUTHOR_ARTICLES
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
"No id"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
langs
.
get
(
PageTypes
.
AUTHOR_ARTICLES
.
getLangeLabel
())
+
" ["
+
langs
.
get
(
"pageNumLabel"
)
+
"="
+
currentPageNum
+
", "
+
langs
.
get
(
"authorLabel"
)
+
"="
+
author
.
getString
(
User
.
USER_NAME
)
+
"]"
);
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
requestURI
);
final
String
authorEmail
=
author
.
getString
(
User
.
USER_EMAIL
);
final
String
authorEmail
=
author
.
getString
(
User
.
USER_EMAIL
);
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByAuthorEmail
(
authorEmail
,
currentPageNum
,
pageSize
);
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByAuthorEmail
(
authorEmail
,
currentPageNum
,
pageSize
);
...
@@ -731,8 +723,7 @@ public class ArticleProcessor {
...
@@ -731,8 +723,7 @@ public class ArticleProcessor {
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
prepareShowAuthorArticles
(
pageNums
,
dataModel
,
pageCount
,
currentPageNum
,
articles
,
author
);
prepareShowAuthorArticles
(
pageNums
,
dataModel
,
pageCount
,
currentPageNum
,
articles
,
author
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
AUTHOR_ARTICLES
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
...
@@ -757,7 +748,7 @@ public class ArticleProcessor {
...
@@ -757,7 +748,7 @@ public class ArticleProcessor {
@RequestProcessing
(
value
=
"/archives/**"
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
"/archives/**"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showArchiveArticles
(
final
HTTPRequestContext
context
,
public
void
showArchiveArticles
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
{
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -825,20 +816,9 @@ public class ArticleProcessor {
...
@@ -825,20 +816,9 @@ public class ArticleProcessor {
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
final
String
cachedTitle
=
prepareShowArchiveArticles
(
preference
,
dataModel
,
articles
,
currentPageNum
,
pageCount
,
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
archiveDateString
,
archiveDate
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
DATE_ARTICLES
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
DATE_ARTICLES
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
archiveDateId
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
cachedTitle
+
" ["
+
langs
.
get
(
"pageNumLabel"
)
+
"="
+
currentPageNum
+
"]"
);
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
requestURI
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
@@ -895,7 +875,7 @@ public class ArticleProcessor {
...
@@ -895,7 +875,7 @@ public class ArticleProcessor {
final
String
articleId
=
article
.
optString
(
Keys
.
OBJECT_ID
);
final
String
articleId
=
article
.
optString
(
Keys
.
OBJECT_ID
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Article[id={0}]"
,
articleId
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Article[id={0}]"
,
articleId
);
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
renderer
.
setTemplateName
(
"article.ftl"
);
renderer
.
setTemplateName
(
"article.ftl"
);
...
@@ -917,12 +897,6 @@ public class ArticleProcessor {
...
@@ -917,12 +897,6 @@ public class ArticleProcessor {
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
ARTICLE
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
articleId
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
article
.
getString
(
Article
.
ARTICLE_TITLE
));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
article
.
getString
(
Article
.
ARTICLE_PERMALINK
));
request
.
setAttribute
(
PageCaches
.
CACHED_PWD
,
article
.
optString
(
Article
.
ARTICLE_VIEW_PWD
));
// For <meta name="description" content="${article.articleAbstract}"/>
// For <meta name="description" content="${article.articleAbstract}"/>
final
String
metaDescription
=
Jsoup
.
parse
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
)).
text
();
final
String
metaDescription
=
Jsoup
.
parse
(
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
)).
text
();
...
@@ -947,9 +921,7 @@ public class ArticleProcessor {
...
@@ -947,9 +921,7 @@ public class ArticleProcessor {
prepareShowArticle
(
preference
,
dataModel
,
article
);
prepareShowArticle
(
preference
,
dataModel
,
article
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
ARTICLE
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
...
...
core/src/main/java/org/b3log/solo/processor/CacheProcessor.java
deleted
100644 → 0
View file @
6db5b6e3
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 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
java.io.IOException
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.DoNothingRenderer
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.service.UserMgmtService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.json.JSONObject
;
/**
* Cache processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.2, Aug 9, 2012
* @since 0.3.1
*/
@RequestProcessor
public
class
CacheProcessor
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CacheProcessor
.
class
.
getName
());
/**
* User query service.
*/
@Inject
private
UserQueryService
userQueryService
;
/**
* User management service.
*/
@Inject
private
UserMgmtService
userMgmtService
;
/**
* Page caches.
*/
@Inject
private
PageCaches
pageCaches
;
/**
* Clears cache with the specified context.
*
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @throws IOException io exception
*/
@RequestProcessing
(
value
=
"/clear-cache.do"
,
method
=
HTTPRequestMethod
.
POST
)
public
void
clearCache
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
IOException
{
userMgmtService
.
tryLogInWithCookie
(
request
,
response
);
if
(!
userQueryService
.
isAdminLoggedIn
(
request
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
}
try
{
final
JSONObject
requestJSONObject
=
Requests
.
parseRequestJSONObject
(
request
,
response
);
final
String
all
=
requestJSONObject
.
optString
(
"all"
);
if
(
Strings
.
isEmptyOrNull
(
all
))
{
// Just clears single page cache
final
String
uri
=
requestJSONObject
.
optString
(
Common
.
URI
);
clearPageCache
(
uri
);
}
else
{
// Clears all page caches
clearAllPageCache
();
}
context
.
setRenderer
(
new
DoNothingRenderer
());
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
}
}
/**
* Clears a page cache specified by the given URI.
*
* @param uri the specified URI
*/
private
void
clearPageCache
(
final
String
uri
)
{
final
String
pageCacheKey
=
PageCaches
.
getPageCacheKey
(
uri
,
null
);
LOGGER
.
log
(
Level
.
INFO
,
"Clears page cache[pageCacheKey={0}]"
,
pageCacheKey
);
PageCaches
.
remove
(
pageCacheKey
);
}
/**
* Clears all page cache.
*/
private
void
clearAllPageCache
()
{
pageCaches
.
removeAll
();
}
}
core/src/main/java/org/b3log/solo/processor/ErrorProcessor.java
View file @
31a5d8b5
...
@@ -108,7 +108,7 @@ public class ErrorProcessor {
...
@@ -108,7 +108,7 @@ public class ErrorProcessor {
dataModel
.
putAll
(
langs
);
dataModel
.
putAll
(
langs
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
dataModel
.
put
(
Common
.
LOGIN_URL
,
userService
.
createLoginURL
(
Common
.
ADMIN_INDEX_URI
));
dataModel
.
put
(
Common
.
LOGIN_URL
,
userService
.
createLoginURL
(
Common
.
ADMIN_INDEX_URI
));
...
...
core/src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
31a5d8b5
...
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.Pagination
;
import
org.b3log.latke.model.Pagination
;
...
@@ -38,13 +37,12 @@ import org.b3log.latke.servlet.URIPatternMode;
...
@@ -38,13 +37,12 @@ import org.b3log.latke.servlet.URIPatternMode;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.renderer.FrontRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Skins
;
...
@@ -94,7 +92,7 @@ public class IndexProcessor {
...
@@ -94,7 +92,7 @@ public class IndexProcessor {
*/
*/
@RequestProcessing
(
value
=
{
"/\\d*"
,
""
},
uriPatternsMode
=
URIPatternMode
.
REGEX
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
{
"/\\d*"
,
""
},
uriPatternsMode
=
URIPatternMode
.
REGEX
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showIndex
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
{
public
void
showIndex
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -109,18 +107,10 @@ public class IndexProcessor {
...
@@ -109,18 +107,10 @@ public class IndexProcessor {
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
"No id"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
langPropsService
.
get
(
PageTypes
.
INDEX
.
getLangeLabel
())
+
" ["
+
langPropsService
.
get
(
"pageNumLabel"
)
+
"="
+
currentPageNum
+
"]"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langPropsService
.
get
(
PageTypes
.
INDEX
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
requestURI
);
filler
.
fillIndexArticles
(
request
,
dataModel
,
currentPageNum
,
preference
);
filler
.
fillIndexArticles
(
request
,
dataModel
,
currentPageNum
,
preference
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
INDEX
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
dataModel
.
put
(
Pagination
.
PAGINATION_CURRENT_PAGE_NUM
,
currentPageNum
);
dataModel
.
put
(
Pagination
.
PAGINATION_CURRENT_PAGE_NUM
,
currentPageNum
);
...
@@ -171,13 +161,6 @@ public class IndexProcessor {
...
@@ -171,13 +161,6 @@ public class IndexProcessor {
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
Keys
.
fillRuntime
(
dataModel
);
Keys
.
fillRuntime
(
dataModel
);
filler
.
fillMinified
(
dataModel
);
filler
.
fillMinified
(
dataModel
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
KILL_BROWSER
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
"No id"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
"Kill Browser Page"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
KILL_BROWSER
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
request
.
getRequestURI
());
}
catch
(
final
ServiceException
e
)
{
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
@@ -272,8 +255,6 @@ public class IndexProcessor {
...
@@ -272,8 +255,6 @@ public class IndexProcessor {
final
String
pageContent
=
stringWriter
.
toString
();
final
String
pageContent
=
stringWriter
.
toString
();
context
.
getRequest
().
setAttribute
(
PageCaches
.
CACHED_CONTENT
,
pageContent
);
writer
.
write
(
pageContent
);
writer
.
write
(
pageContent
);
writer
.
flush
();
writer
.
flush
();
writer
.
close
();
writer
.
close
();
...
...
core/src/main/java/org/b3log/solo/processor/PageProcessor.java
View file @
31a5d8b5
...
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
...
@@ -33,12 +32,11 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
...
@@ -33,12 +32,11 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.renderer.FrontRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.CommentQueryService
;
import
org.b3log.solo.service.CommentQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
@@ -93,7 +91,7 @@ public class PageProcessor {
...
@@ -93,7 +91,7 @@ public class PageProcessor {
*/
*/
@RequestProcessing
(
value
=
"/page"
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
"/page"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showPage
(
final
HTTPRequestContext
context
)
{
public
void
showPage
(
final
HTTPRequestContext
context
)
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -115,8 +113,6 @@ public class PageProcessor {
...
@@ -115,8 +113,6 @@ public class PageProcessor {
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
PAGE
.
getLangeLabel
()));
// See PermalinkFiler#dispatchToArticleOrPageProcessor()
// See PermalinkFiler#dispatchToArticleOrPageProcessor()
final
JSONObject
page
=
(
JSONObject
)
request
.
getAttribute
(
Page
.
PAGE
);
final
JSONObject
page
=
(
JSONObject
)
request
.
getAttribute
(
Page
.
PAGE
);
...
@@ -127,10 +123,6 @@ public class PageProcessor {
...
@@ -127,10 +123,6 @@ public class PageProcessor {
final
String
pageId
=
page
.
getString
(
Keys
.
OBJECT_ID
);
final
String
pageId
=
page
.
getString
(
Keys
.
OBJECT_ID
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
pageId
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
page
.
getString
(
Page
.
PAGE_TITLE
));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
page
.
getString
(
Page
.
PAGE_PERMALINK
));
page
.
put
(
Common
.
COMMENTABLE
,
page
.
getBoolean
(
Page
.
PAGE_COMMENTABLE
));
page
.
put
(
Common
.
COMMENTABLE
,
page
.
getBoolean
(
Page
.
PAGE_COMMENTABLE
));
page
.
put
(
Common
.
PERMALINK
,
page
.
getString
(
Page
.
PAGE_PERMALINK
));
page
.
put
(
Common
.
PERMALINK
,
page
.
getString
(
Page
.
PAGE_PERMALINK
));
dataModel
.
put
(
Page
.
PAGE
,
page
);
dataModel
.
put
(
Page
.
PAGE
,
page
);
...
@@ -149,9 +141,8 @@ public class PageProcessor {
...
@@ -149,9 +141,8 @@ public class PageProcessor {
Stopwatchs
.
end
();
Stopwatchs
.
end
();
}
}
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
PAGE
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/RepairProcessor.java
View file @
31a5d8b5
...
@@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
...
@@ -134,12 +133,6 @@ public class RepairProcessor {
...
@@ -134,12 +133,6 @@ public class RepairProcessor {
@Inject
@Inject
private
StatisticMgmtService
statisticMgmtService
;
private
StatisticMgmtService
statisticMgmtService
;
/**
* Page caches.
*/
@Inject
private
PageCaches
pageCaches
;
/**
/**
* Removes unused properties of each article.
* Removes unused properties of each article.
*
*
...
@@ -216,8 +209,6 @@ public class RepairProcessor {
...
@@ -216,8 +209,6 @@ public class RepairProcessor {
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
try
{
try
{
pageCaches
.
removeAll
();
// Clears all first
final
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
final
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
if
(
statistic
.
has
(
Statistic
.
STATISTIC_BLOG_COMMENT_COUNT
)
&&
statistic
.
has
(
Statistic
.
STATISTIC_BLOG_ARTICLE_COUNT
))
{
if
(
statistic
.
has
(
Statistic
.
STATISTIC_BLOG_COMMENT_COUNT
)
&&
statistic
.
has
(
Statistic
.
STATISTIC_BLOG_ARTICLE_COUNT
))
{
...
@@ -383,8 +374,6 @@ public class RepairProcessor {
...
@@ -383,8 +374,6 @@ public class RepairProcessor {
public
void
removeAllDataPOST
(
final
HTTPRequestContext
context
)
{
public
void
removeAllDataPOST
(
final
HTTPRequestContext
context
)
{
LOGGER
.
info
(
"Removing all data...."
);
LOGGER
.
info
(
"Removing all data...."
);
pageCaches
.
removeAll
();
boolean
succeed
=
false
;
boolean
succeed
=
false
;
try
{
try
{
...
...
core/src/main/java/org/b3log/solo/processor/SitemapProcessor.java
View file @
31a5d8b5
...
@@ -141,13 +141,9 @@ public class SitemapProcessor {
...
@@ -141,13 +141,9 @@ public class SitemapProcessor {
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setFilter
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
)).
addSort
(
final
Query
query
=
new
Query
().
setCurrentPageNum
(
1
).
setFilter
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
)).
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
// Closes cache avoid Java heap space out of memory while caching query results
// XXX: maybe out of memory
articleRepository
.
setCacheEnabled
(
false
);
final
JSONObject
articleResult
=
articleRepository
.
get
(
query
);
final
JSONObject
articleResult
=
articleRepository
.
get
(
query
);
articleRepository
.
setCacheEnabled
(
true
);
// Restores cache
final
JSONArray
articles
=
articleResult
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
articles
=
articleResult
.
getJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
...
...
core/src/main/java/org/b3log/solo/processor/StatProcessor.java
View file @
31a5d8b5
...
@@ -17,9 +17,7 @@ package org.b3log.solo.processor;
...
@@ -17,9 +17,7 @@ package org.b3log.solo.processor;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
...
@@ -40,7 +38,7 @@ import org.b3log.solo.service.StatisticMgmtService;
...
@@ -40,7 +38,7 @@ import org.b3log.solo.service.StatisticMgmtService;
* <p>
* <p>
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.
1.9, Mar 6
, 2013
* @version 1.0.
2.0, Oct 12
, 2013
* @since 0.4.0
* @since 0.4.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -68,22 +66,4 @@ public class StatProcessor {
...
@@ -68,22 +66,4 @@ public class StatProcessor {
statisticMgmtService
.
removeExpiredOnlineVisitor
();
statisticMgmtService
.
removeExpiredOnlineVisitor
();
}
}
/**
* Increments Blog/Articles view counter.
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/console/stat/viewcnt"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
viewCounter
(
final
HTTPRequestContext
context
)
{
LOGGER
.
log
(
Level
.
INFO
,
"Sync statistic from memcache to repository"
);
context
.
setRenderer
(
new
DoNothingRenderer
());
try
{
statisticMgmtService
.
flushStatistic
();
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Flushes statistic to repository failed"
,
e
);
}
}
}
}
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
31a5d8b5
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.Pagination
;
import
org.b3log.latke.model.Pagination
;
...
@@ -38,15 +37,14 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
...
@@ -38,15 +37,14 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Paginator
;
import
org.b3log.latke.util.Paginator
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.processor.renderer.FrontRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
@@ -117,7 +115,7 @@ public class TagProcessor {
...
@@ -117,7 +115,7 @@ public class TagProcessor {
*/
*/
@RequestProcessing
(
value
=
"/tags/**"
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
"/tags/**"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
showTagArticles
(
final
HTTPRequestContext
context
)
throws
IOException
{
public
void
showTagArticles
(
final
HTTPRequestContext
context
)
throws
IOException
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -162,16 +160,6 @@ public class TagProcessor {
...
@@ -162,16 +160,6 @@ public class TagProcessor {
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
tagId
);
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
langs
.
get
(
PageTypes
.
TAG_ARTICLES
.
getLangeLabel
())
+
" ["
+
langs
.
get
(
"pageNumLabel"
)
+
"="
+
currentPageNum
+
", "
+
langs
.
get
(
"tagLabel"
)
+
"="
+
tagTitle
+
"]"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
TAG_ARTICLES
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
requestURI
);
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByTag
(
tagId
,
currentPageNum
,
pageSize
);
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByTag
(
tagId
,
currentPageNum
,
pageSize
);
if
(
articles
.
isEmpty
())
{
if
(
articles
.
isEmpty
())
{
...
@@ -210,9 +198,8 @@ public class TagProcessor {
...
@@ -210,9 +198,8 @@ public class TagProcessor {
dataModel
.
put
(
Keys
.
OBJECT_ID
,
tagId
);
dataModel
.
put
(
Keys
.
OBJECT_ID
,
tagId
);
dataModel
.
put
(
Tag
.
TAG
,
tag
);
dataModel
.
put
(
Tag
.
TAG
,
tag
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
TAG_ARTICLES
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
}
catch
(
final
ServiceException
e
)
{
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
@@ -269,7 +256,7 @@ public class TagProcessor {
...
@@ -269,7 +256,7 @@ public class TagProcessor {
*/
*/
@RequestProcessing
(
value
=
{
"/tags.html"
},
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
{
"/tags.html"
},
method
=
HTTPRequestMethod
.
GET
)
public
void
showTags
(
final
HTTPRequestContext
context
)
{
public
void
showTags
(
final
HTTPRequestContext
context
)
{
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -289,13 +276,6 @@ public class TagProcessor {
...
@@ -289,13 +276,6 @@ public class TagProcessor {
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
"No id"
);
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
langs
.
get
(
PageTypes
.
TAGS
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
TAGS
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
"/tags.html"
);
final
List
<
JSONObject
>
tags
=
tagQueryService
.
getTags
();
final
List
<
JSONObject
>
tags
=
tagQueryService
.
getTags
();
tagQueryService
.
removeForUnpublishedArticles
(
tags
);
tagQueryService
.
removeForUnpublishedArticles
(
tags
);
...
@@ -303,9 +283,8 @@ public class TagProcessor {
...
@@ -303,9 +283,8 @@ public class TagProcessor {
dataModel
.
put
(
Tag
.
TAGS
,
tags
);
dataModel
.
put
(
Tag
.
TAGS
,
tags
);
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
TAGS
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/UpgradeProcessor.java
View file @
31a5d8b5
...
@@ -177,7 +177,6 @@ public class UpgradeProcessor {
...
@@ -177,7 +177,6 @@ public class UpgradeProcessor {
private
void
upgrade
()
throws
Exception
{
private
void
upgrade
()
throws
Exception
{
LOGGER
.
log
(
Level
.
INFO
,
"Upgrading from version [{0}] to version [{1}]...."
,
FROM_VER
,
TO_VER
);
LOGGER
.
log
(
Level
.
INFO
,
"Upgrading from version [{0}] to version [{1}]...."
,
FROM_VER
,
TO_VER
);
articleRepository
.
setCacheEnabled
(
false
);
Transaction
transaction
=
null
;
Transaction
transaction
=
null
;
try
{
try
{
...
@@ -213,8 +212,6 @@ public class UpgradeProcessor {
...
@@ -213,8 +212,6 @@ public class UpgradeProcessor {
LOGGER
.
log
(
Level
.
ERROR
,
"Upgrade failed!"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Upgrade failed!"
,
e
);
throw
new
Exception
(
"Upgrade failed from version ["
+
FROM_VER
+
"] to version ["
+
TO_VER
+
']'
);
throw
new
Exception
(
"Upgrade failed from version ["
+
FROM_VER
+
"] to version ["
+
TO_VER
+
']'
);
}
finally
{
articleRepository
.
setCacheEnabled
(
true
);
}
}
LOGGER
.
log
(
Level
.
INFO
,
"Upgraded from version [{0}] to version [{1}] successfully :-)"
,
FROM_VER
,
TO_VER
);
LOGGER
.
log
(
Level
.
INFO
,
"Upgraded from version [{0}] to version [{1}] successfully :-)"
,
FROM_VER
,
TO_VER
);
...
...
core/src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
View file @
31a5d8b5
...
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
...
@@ -33,11 +32,10 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
...
@@ -33,11 +32,10 @@ import org.b3log.latke.servlet.HTTPRequestMethod;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer
;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.renderer.FrontRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Skins
;
...
@@ -102,7 +100,7 @@ public class UserTemplateProcessor {
...
@@ -102,7 +100,7 @@ public class UserTemplateProcessor {
templateName
=
StringUtils
.
substringBefore
(
templateName
,
"."
)
+
".ftl"
;
templateName
=
StringUtils
.
substringBefore
(
templateName
,
"."
)
+
".ftl"
;
LOGGER
.
log
(
Level
.
DEBUG
,
"Shows page[requestURI={0}, templateName={1}]"
,
new
Object
[]
{
requestURI
,
templateName
});
LOGGER
.
log
(
Level
.
DEBUG
,
"Shows page[requestURI={0}, templateName={1}]"
,
new
Object
[]
{
requestURI
,
templateName
});
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
ont
Renderer
();
final
AbstractFreeMarkerRenderer
renderer
=
new
Fr
eeMarker
Renderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
renderer
.
setTemplateName
(
templateName
);
renderer
.
setTemplateName
(
templateName
);
...
@@ -127,16 +125,10 @@ public class UserTemplateProcessor {
...
@@ -127,16 +125,10 @@ public class UserTemplateProcessor {
dataModel
.
putAll
(
langs
);
dataModel
.
putAll
(
langs
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
dataModel
.
put
(
Keys
.
PAGE_TYPE
,
PageTypes
.
USER_TEMPLATE
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
dataModel
,
preference
);
filler
.
fillUserTemplate
(
template
,
dataModel
,
preference
);
filler
.
fillUserTemplate
(
template
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
request
.
setAttribute
(
PageCaches
.
CACHED_OID
,
"No id"
);
request
.
setAttribute
(
PageCaches
.
CACHED_TITLE
,
requestURI
);
request
.
setAttribute
(
PageCaches
.
CACHED_TYPE
,
langs
.
get
(
PageTypes
.
USER_TEMPLATE
.
getLangeLabel
()));
request
.
setAttribute
(
PageCaches
.
CACHED_LINK
,
requestURI
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
core/src/main/java/org/b3log/solo/processor/renderer/FrontRenderer.java
deleted
100644 → 0
View file @
6db5b6e3
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 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
.
renderer
;
import
java.io.PrintWriter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.renderer.freemarker.CacheFreeMarkerRenderer
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.processor.util.TopBars
;
import
org.b3log.solo.service.StatisticMgmtService
;
/**
* <a href="http://freemarker.org">FreeMarker</a> HTTP response
* renderer.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.7, Jul 16, 2012
* @since 0.3.1
*/
public
final
class
FrontRenderer
extends
CacheFreeMarkerRenderer
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
FrontRenderer
.
class
.
getName
());
/**
* {@inheritDoc}
*
* <p>
* Puts the top bar replacement flag into data model.
* </p>
*/
@Override
protected
void
beforeRender
(
final
HTTPRequestContext
context
)
throws
Exception
{
LOGGER
.
log
(
Level
.
TRACE
,
"Before render...."
);
getDataModel
().
put
(
Common
.
TOP_BAR_REPLACEMENT_FLAG_KEY
,
Common
.
TOP_BAR_REPLACEMENT_FLAG
);
}
@Override
protected
void
doRender
(
final
String
html
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
LOGGER
.
log
(
Level
.
TRACE
,
"Do render...."
);
response
.
setContentType
(
"text/html"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
writer
;
try
{
writer
=
response
.
getWriter
();
}
catch
(
final
Exception
e
)
{
writer
=
new
PrintWriter
(
response
.
getOutputStream
());
}
if
(
response
.
isCommitted
())
{
// response has been sent redirect
writer
.
flush
();
writer
.
close
();
return
;
}
final
String
pageContent
=
(
String
)
request
.
getAttribute
(
PageCaches
.
CACHED_CONTENT
);
String
output
=
html
;
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
if
(
null
!=
pageContent
)
{
final
TopBars
topbars
=
beanManager
.
getReference
(
TopBars
.
class
);
// Adds the top bar HTML content for output
final
String
topBarHTML
=
topbars
.
getTopBarHTML
(
request
,
response
);
output
=
html
.
replace
(
Common
.
TOP_BAR_REPLACEMENT_FLAG
,
topBarHTML
);
}
final
StatisticMgmtService
statisticMgmtService
=
beanManager
.
getReference
(
StatisticMgmtService
.
class
);
// Inc blog view count
try
{
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Incs blog view count failed"
,
e
);
}
// Write out
writer
.
write
(
output
);
writer
.
flush
();
writer
.
close
();
}
/**
* {@inheritDoc}
*
* <p>
* Skips page caching if requested by mobile device.
* </p>
*/
@Override
protected
void
afterRender
(
final
HTTPRequestContext
context
)
throws
Exception
{
LOGGER
.
log
(
Level
.
TRACE
,
"After render...."
);
final
HttpServletRequest
request
=
context
.
getRequest
();
if
(
"mobile"
.
equals
((
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
)))
{
// Skips page caching if requested by mobile device
return
;
}
super
.
afterRender
(
context
);
}
}
core/src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
31a5d8b5
...
@@ -24,6 +24,7 @@ import java.util.List;
...
@@ -24,6 +24,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.apache.commons.lang.StringEscapeUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
...
@@ -76,6 +77,12 @@ public class Filler {
...
@@ -76,6 +77,12 @@ public class Filler {
*/
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Filler
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Filler
.
class
.
getName
());
/**
* Topbar utilities.
*/
@Inject
private
TopBars
topBars
;
/**
/**
* Article repository.
* Article repository.
*/
*/
...
@@ -552,15 +559,21 @@ public class Filler {
...
@@ -552,15 +559,21 @@ public class Filler {
* Fills header.ftl.
* Fills header.ftl.
*
*
* @param request the specified HTTP servlet request
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @param dataModel data model
* @param dataModel data model
* @param preference the specified preference
* @param preference the specified preference
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
void
fillBlogHeader
(
final
HttpServletRequest
request
,
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
preference
)
public
void
fillBlogHeader
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
preference
)
throws
ServiceException
{
throws
ServiceException
{
Stopwatchs
.
start
(
"Fill Header"
);
Stopwatchs
.
start
(
"Fill Header"
);
try
{
try
{
LOGGER
.
debug
(
"Filling header...."
);
LOGGER
.
debug
(
"Filling header...."
);
final
String
topBarHTML
=
topBars
.
getTopBarHTML
(
request
,
response
);
dataModel
.
put
(
Common
.
TOP_BAR
,
topBarHTML
);
dataModel
.
put
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
preference
.
getString
(
Preference
.
LOCALE_STRING
));
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
preference
.
getString
(
Preference
.
LOCALE_STRING
));
...
...
core/src/main/java/org/b3log/solo/processor/util/TopBars.java
View file @
31a5d8b5
...
@@ -136,8 +136,6 @@ public class TopBars {
...
@@ -136,8 +136,6 @@ public class TopBars {
topBarModel
.
put
(
Common
.
IS_ADMIN
,
Role
.
ADMIN_ROLE
.
equals
(
currentUser
.
getString
(
User
.
USER_ROLE
)));
topBarModel
.
put
(
Common
.
IS_ADMIN
,
Role
.
ADMIN_ROLE
.
equals
(
currentUser
.
getString
(
User
.
USER_ROLE
)));
topBarModel
.
put
(
Common
.
IS_VISITOR
,
Role
.
VISITOR_ROLE
.
equals
(
currentUser
.
getString
(
User
.
USER_ROLE
)));
topBarModel
.
put
(
Common
.
IS_VISITOR
,
Role
.
VISITOR_ROLE
.
equals
(
currentUser
.
getString
(
User
.
USER_ROLE
)));
topBarModel
.
put
(
"clearAllCacheLabel"
,
langPropsService
.
get
(
"clearAllCacheLabel"
));
topBarModel
.
put
(
"clearCacheLabel"
,
langPropsService
.
get
(
"clearCacheLabel"
));
topBarModel
.
put
(
"adminLabel"
,
langPropsService
.
get
(
"adminLabel"
));
topBarModel
.
put
(
"adminLabel"
,
langPropsService
.
get
(
"adminLabel"
));
topBarModel
.
put
(
"logoutLabel"
,
langPropsService
.
get
(
"logoutLabel"
));
topBarModel
.
put
(
"logoutLabel"
,
langPropsService
.
get
(
"logoutLabel"
));
...
...
core/src/main/java/org/b3log/solo/repository/impl/CommentRepositoryImpl.java
View file @
31a5d8b5
...
@@ -16,12 +16,10 @@
...
@@ -16,12 +16,10 @@
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
java.io.Serializable
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.cache.Cache
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.AbstractRepository
;
import
org.b3log.latke.repository.AbstractRepository
;
...
@@ -68,11 +66,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
...
@@ -68,11 +66,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
super
(
Comment
.
COMMENT
);
super
(
Comment
.
COMMENT
);
}
}
/**
* Recent comments query results cache key.
*/
public
static
final
String
RECENT_CMTS_CACHE_KEY
=
"recentCMTs"
;
@Override
@Override
public
int
removeComments
(
final
String
onId
)
throws
RepositoryException
{
public
int
removeComments
(
final
String
onId
)
throws
RepositoryException
{
final
List
<
JSONObject
>
comments
=
getComments
(
onId
,
1
,
Integer
.
MAX_VALUE
);
final
List
<
JSONObject
>
comments
=
getComments
(
onId
,
1
,
Integer
.
MAX_VALUE
);
...
@@ -104,15 +97,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
...
@@ -104,15 +97,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
@Override
@Override
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
List
<
JSONObject
>
getRecentComments
(
final
int
num
)
throws
RepositoryException
{
public
List
<
JSONObject
>
getRecentComments
(
final
int
num
)
throws
RepositoryException
{
if
(
isCacheEnabled
())
{
final
Cache
<
String
,
Serializable
>
cache
=
getCache
();
final
Object
ret
=
cache
.
get
(
RECENT_CMTS_CACHE_KEY
);
if
(
null
!=
ret
)
{
return
(
List
<
JSONObject
>)
ret
;
}
}
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
1
);
...
@@ -126,12 +110,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
...
@@ -126,12 +110,6 @@ public class CommentRepositoryImpl extends AbstractRepository implements Comment
// Removes unpublished article related comments
// Removes unpublished article related comments
removeForUnpublishedArticles
(
ret
);
removeForUnpublishedArticles
(
ret
);
if
(
isCacheEnabled
())
{
final
Cache
<
String
,
Serializable
>
cache
=
getCache
();
cache
.
put
(
RECENT_CMTS_CACHE_KEY
,
(
Serializable
)
ret
);
}
return
ret
;
return
ret
;
}
}
...
...
core/src/main/java/org/b3log/solo/repository/impl/StatisticRepositoryImpl.java
View file @
31a5d8b5
...
@@ -16,14 +16,10 @@
...
@@ -16,14 +16,10 @@
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.repository.AbstractRepository
;
import
org.b3log.latke.repository.AbstractRepository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.repository.StatisticRepository
;
import
org.b3log.solo.repository.StatisticRepository
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.json.JSONObject
;
/**
/**
...
@@ -42,13 +38,4 @@ public class StatisticRepositoryImpl extends AbstractRepository implements Stati
...
@@ -42,13 +38,4 @@ public class StatisticRepositoryImpl extends AbstractRepository implements Stati
public
StatisticRepositoryImpl
()
{
public
StatisticRepositoryImpl
()
{
super
(
Statistic
.
STATISTIC
);
super
(
Statistic
.
STATISTIC
);
}
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
jsonObject
)
throws
RepositoryException
{
super
.
update
(
id
,
jsonObject
);
if
(
Latkes
.
isDataCacheEnabled
())
{
getCache
().
put
(
StatisticMgmtService
.
REPOSITORY_CACHE_KEY_PREFIX
+
Statistic
.
STATISTIC
,
jsonObject
);
}
}
}
}
core/src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
31a5d8b5
...
@@ -611,7 +611,6 @@ public class ArticleMgmtService {
...
@@ -611,7 +611,6 @@ public class ArticleMgmtService {
throws
ServiceException
{
throws
ServiceException
{
final
Transaction
transaction
=
articleRepository
.
beginTransaction
();
final
Transaction
transaction
=
articleRepository
.
beginTransaction
();
transaction
.
clearQueryCache
(
false
);
try
{
try
{
final
List
<
JSONObject
>
randomArticles
=
articleRepository
.
getRandomly
(
updateCnt
);
final
List
<
JSONObject
>
randomArticles
=
articleRepository
.
getRandomly
(
updateCnt
);
...
...
core/src/main/java/org/b3log/solo/service/InitService.java
View file @
31a5d8b5
...
@@ -561,7 +561,6 @@ public class InitService {
...
@@ -561,7 +561,6 @@ public class InitService {
ret
.
put
(
ENABLE_ARTICLE_UPDATE_HINT
,
Default
.
DEFAULT_ENABLE_ARTICLE_UPDATE_HINT
);
ret
.
put
(
ENABLE_ARTICLE_UPDATE_HINT
,
Default
.
DEFAULT_ENABLE_ARTICLE_UPDATE_HINT
);
ret
.
put
(
SIGNS
,
Default
.
DEFAULT_SIGNS
);
ret
.
put
(
SIGNS
,
Default
.
DEFAULT_SIGNS
);
ret
.
put
(
TIME_ZONE_ID
,
Default
.
DEFAULT_TIME_ZONE
);
ret
.
put
(
TIME_ZONE_ID
,
Default
.
DEFAULT_TIME_ZONE
);
ret
.
put
(
PAGE_CACHE_ENABLED
,
Default
.
DEFAULT_PAGE_CACHE_ENABLED
);
ret
.
put
(
ALLOW_VISIT_DRAFT_VIA_PERMALINK
,
Default
.
DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
ret
.
put
(
ALLOW_VISIT_DRAFT_VIA_PERMALINK
,
Default
.
DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
ret
.
put
(
COMMENTABLE
,
Default
.
DEFAULT_COMMENTABLE
);
ret
.
put
(
COMMENTABLE
,
Default
.
DEFAULT_COMMENTABLE
);
ret
.
put
(
VERSION
,
SoloServletListener
.
VERSION
);
ret
.
put
(
VERSION
,
SoloServletListener
.
VERSION
);
...
@@ -607,12 +606,6 @@ public class InitService {
...
@@ -607,12 +606,6 @@ public class InitService {
TimeZones
.
setTimeZone
(
INIT_TIME_ZONE_ID
);
TimeZones
.
setTimeZone
(
INIT_TIME_ZONE_ID
);
if
(
Default
.
DEFAULT_PAGE_CACHE_ENABLED
)
{
Latkes
.
enablePageCache
();
}
else
{
Latkes
.
disablePageCache
();
}
ret
.
put
(
Keys
.
OBJECT_ID
,
PREFERENCE
);
ret
.
put
(
Keys
.
OBJECT_ID
,
PREFERENCE
);
preferenceRepository
.
add
(
ret
);
preferenceRepository
.
add
(
ret
);
...
...
core/src/main/java/org/b3log/solo/service/PermalinkQueryService.java
View file @
31a5d8b5
...
@@ -65,7 +65,7 @@ public class PermalinkQueryService {
...
@@ -65,7 +65,7 @@ public class PermalinkQueryService {
"/login"
,
"/logout"
,
"/forgot"
,
"/get-article-content"
,
"/admin-index.do"
,
"/admin-article.do"
,
"/admin-article-list.do"
,
"/login"
,
"/logout"
,
"/forgot"
,
"/get-article-content"
,
"/admin-index.do"
,
"/admin-article.do"
,
"/admin-article-list.do"
,
"/admin-link-list.do"
,
"/admin-preference.do"
,
"/admin-file-list.do"
,
"/admin-page-list.do"
,
"/admin-others.do"
,
"/admin-link-list.do"
,
"/admin-preference.do"
,
"/admin-file-list.do"
,
"/admin-page-list.do"
,
"/admin-others.do"
,
"/admin-draft-list.do"
,
"/admin-user-list.do"
,
"/admin-plugin-list.do"
,
"/admin-main.do"
,
"/admin-about.do"
,
"/admin-label"
,
"/admin-draft-list.do"
,
"/admin-user-list.do"
,
"/admin-plugin-list.do"
,
"/admin-main.do"
,
"/admin-about.do"
,
"/admin-label"
,
"/admin-about.do"
,
"/rm-all-data.do"
,
"/init"
,
"/
clear-cache.do"
,
"/
register.html"
"/admin-about.do"
,
"/rm-all-data.do"
,
"/init"
,
"/register.html"
};
};
/**
/**
...
...
core/src/main/java/org/b3log/solo/service/PluginMgmtService.java
View file @
31a5d8b5
...
@@ -93,9 +93,6 @@ public class PluginMgmtService {
...
@@ -93,9 +93,6 @@ public class PluginMgmtService {
final
JSONArray
pluginArray
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
JSONArray
pluginArray
=
result
.
getJSONArray
(
Keys
.
RESULTS
);
final
List
<
JSONObject
>
persistedPlugins
=
CollectionUtils
.
jsonArrayToList
(
pluginArray
);
final
List
<
JSONObject
>
persistedPlugins
=
CollectionUtils
.
jsonArrayToList
(
pluginArray
);
// Disables plugin repository cache to avoid remove all cache
pluginRepository
.
setCacheEnabled
(
false
);
try
{
try
{
// Reads plugin status from datastore and clear plugin datastore
// Reads plugin status from datastore and clear plugin datastore
for
(
final
JSONObject
oldPluginDesc
:
persistedPlugins
)
{
for
(
final
JSONObject
oldPluginDesc
:
persistedPlugins
)
{
...
@@ -131,8 +128,6 @@ public class PluginMgmtService {
...
@@ -131,8 +128,6 @@ public class PluginMgmtService {
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Refresh plugins failed"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Refresh plugins failed"
,
e
);
}
}
pluginRepository
.
setCacheEnabled
(
true
);
}
}
/**
/**
...
...
core/src/main/java/org/b3log/solo/service/PluginQueryService.java
View file @
31a5d8b5
...
@@ -132,7 +132,7 @@ public class PluginQueryService {
...
@@ -132,7 +132,7 @@ public class PluginQueryService {
}
}
/**
/**
* get the setting(json formatter) of the plugin
(from database not cache which does not contains it)
by the specified pluginoId.
* get the setting(json formatter) of the plugin by the specified pluginoId.
*
*
* @param pluginId the specified pluginId
* @param pluginId the specified pluginId
* @return the {@link AbstractPlugin}
* @return the {@link AbstractPlugin}
...
...
core/src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
View file @
31a5d8b5
...
@@ -27,8 +27,6 @@ import java.util.Locale;
...
@@ -27,8 +27,6 @@ import java.util.Locale;
import
java.util.Set
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.RepositoryException
;
...
@@ -81,12 +79,6 @@ public class PreferenceMgmtService {
...
@@ -81,12 +79,6 @@ public class PreferenceMgmtService {
@Inject
@Inject
private
LangPropsService
langPropsService
;
private
LangPropsService
langPropsService
;
/**
* Page caches.
*/
@Inject
private
PageCaches
pageCaches
;
/**
/**
* Loads skins for the specified preference and initializes templates loading.
* Loads skins for the specified preference and initializes templates loading.
*
*
...
@@ -142,7 +134,6 @@ public class PreferenceMgmtService {
...
@@ -142,7 +134,6 @@ public class PreferenceMgmtService {
preference
.
put
(
SKIN_NAME
,
"ease"
);
preference
.
put
(
SKIN_NAME
,
"ease"
);
updatePreference
(
preference
);
updatePreference
(
preference
);
pageCaches
.
removeAll
();
// Clears cache manually
}
}
final
String
skinsString
=
skinArray
.
toString
();
final
String
skinsString
=
skinArray
.
toString
();
...
@@ -151,20 +142,6 @@ public class PreferenceMgmtService {
...
@@ -151,20 +142,6 @@ public class PreferenceMgmtService {
LOGGER
.
log
(
Level
.
INFO
,
"The skins directory has been changed, persists "
+
"the change into preference"
);
LOGGER
.
log
(
Level
.
INFO
,
"The skins directory has been changed, persists "
+
"the change into preference"
);
preference
.
put
(
SKINS
,
skinsString
);
preference
.
put
(
SKINS
,
skinsString
);
updatePreference
(
preference
);
updatePreference
(
preference
);
pageCaches
.
removeAll
();
// Clears cache manually
}
boolean
prefsPageCacheEnabled
=
preference
.
getBoolean
(
Preference
.
PAGE_CACHE_ENABLED
);
if
(!
Latkes
.
isPageCacheEnabled
()
&&
prefsPageCacheEnabled
)
{
preference
.
put
(
Preference
.
PAGE_CACHE_ENABLED
,
false
);
}
prefsPageCacheEnabled
=
preference
.
getBoolean
(
Preference
.
PAGE_CACHE_ENABLED
);
if
(
prefsPageCacheEnabled
)
{
Latkes
.
enablePageCache
();
}
else
{
Latkes
.
disablePageCache
();
}
}
setDirectoryForTemplateLoading
(
preference
.
getString
(
SKIN_DIR_NAME
));
setDirectoryForTemplateLoading
(
preference
.
getString
(
SKIN_DIR_NAME
));
...
@@ -244,7 +221,6 @@ public class PreferenceMgmtService {
...
@@ -244,7 +221,6 @@ public class PreferenceMgmtService {
final
String
skinPath
=
webRootPath
+
Skin
.
SKINS
+
"/"
+
skinDirName
;
final
String
skinPath
=
webRootPath
+
Skin
.
SKINS
+
"/"
+
skinDirName
;
LOGGER
.
log
(
Level
.
DEBUG
,
"Skin path[{0}]"
,
skinPath
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Skin path[{0}]"
,
skinPath
);
Templates
.
CACHE
.
clear
();
preference
.
put
(
Skin
.
SKINS
,
skinArray
.
toString
());
preference
.
put
(
Skin
.
SKINS
,
skinArray
.
toString
());
...
@@ -259,25 +235,6 @@ public class PreferenceMgmtService {
...
@@ -259,25 +235,6 @@ public class PreferenceMgmtService {
preference
.
put
(
ADMIN_EMAIL
,
adminEmail
);
preference
.
put
(
ADMIN_EMAIL
,
adminEmail
);
if
(!
preference
.
has
(
PAGE_CACHE_ENABLED
))
{
preference
.
put
(
PAGE_CACHE_ENABLED
,
oldPreference
.
getBoolean
(
PAGE_CACHE_ENABLED
));
}
else
{
if
(
RuntimeEnv
.
BAE
==
Latkes
.
getRuntimeEnv
())
{
// Ignores user's setting, uses default (https://github.com/b3log/b3log-solo/issues/73)
preference
.
put
(
PAGE_CACHE_ENABLED
,
Default
.
DEFAULT_PAGE_CACHE_ENABLED
);
}
}
final
String
maxPageCntStr
=
Latkes
.
getMaxPageCacheCnt
();
if
(
Integer
.
valueOf
(
maxPageCntStr
)
<=
0
)
{
preference
.
put
(
PAGE_CACHE_ENABLED
,
false
);
}
final
boolean
pageCacheEnabled
=
preference
.
getBoolean
(
Preference
.
PAGE_CACHE_ENABLED
);
Templates
.
enableCache
(
pageCacheEnabled
);
final
String
version
=
oldPreference
.
optString
(
VERSION
);
final
String
version
=
oldPreference
.
optString
(
VERSION
);
if
(!
Strings
.
isEmptyOrNull
(
version
))
{
if
(!
Strings
.
isEmptyOrNull
(
version
))
{
...
@@ -294,12 +251,6 @@ public class PreferenceMgmtService {
...
@@ -294,12 +251,6 @@ public class PreferenceMgmtService {
transaction
.
commit
();
transaction
.
commit
();
Templates
.
MAIN_CFG
.
setDirectoryForTemplateLoading
(
new
File
(
skinPath
));
Templates
.
MAIN_CFG
.
setDirectoryForTemplateLoading
(
new
File
(
skinPath
));
if
(
preference
.
getBoolean
(
PAGE_CACHE_ENABLED
))
{
Latkes
.
enablePageCache
();
}
else
{
Latkes
.
disablePageCache
();
}
}
catch
(
final
JSONException
e
)
{
}
catch
(
final
JSONException
e
)
{
if
(
transaction
.
isActive
())
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
transaction
.
rollback
();
...
...
core/src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
31a5d8b5
...
@@ -16,18 +16,12 @@
...
@@ -16,18 +16,12 @@
package
org
.
b3log
.
solo
.
service
;
package
org
.
b3log
.
solo
.
service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.cache.PageCaches
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.RepositoryException
;
...
@@ -35,10 +29,7 @@ import org.b3log.latke.repository.Transaction;
...
@@ -35,10 +29,7 @@ import org.b3log.latke.repository.Transaction;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.util.CollectionUtils
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.PageTypes
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
...
@@ -71,11 +62,6 @@ public class StatisticMgmtService {
...
@@ -71,11 +62,6 @@ public class StatisticMgmtService {
@Inject
@Inject
private
StatisticRepository
statisticRepository
;
private
StatisticRepository
statisticRepository
;
/**
* Flush size.
*/
private
static
final
int
FLUSH_SIZE
=
30
;
/**
/**
* Language service.
* Language service.
*/
*/
...
@@ -88,17 +74,6 @@ public class StatisticMgmtService {
...
@@ -88,17 +74,6 @@ public class StatisticMgmtService {
@Inject
@Inject
private
ArticleRepository
articleRepository
;
private
ArticleRepository
articleRepository
;
/**
* Page caches.
*/
@Inject
private
PageCaches
pageCaches
;
/**
* Repository cache prefix, refers to GAERepository#CACHE_KEY_PREFIX.
*/
public
static
final
String
REPOSITORY_CACHE_KEY_PREFIX
=
"repository"
;
/**
/**
* Online visitor cache.
* Online visitor cache.
*
*
...
@@ -153,7 +128,6 @@ public class StatisticMgmtService {
...
@@ -153,7 +128,6 @@ public class StatisticMgmtService {
++
blogViewCnt
;
++
blogViewCnt
;
statistic
.
put
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
,
blogViewCnt
);
statistic
.
put
(
Statistic
.
STATISTIC_BLOG_VIEW_COUNT
,
blogViewCnt
);
if
(!
Latkes
.
isDataCacheEnabled
())
{
final
Transaction
transaction
=
statisticRepository
.
beginTransaction
();
final
Transaction
transaction
=
statisticRepository
.
beginTransaction
();
try
{
try
{
...
@@ -167,10 +141,6 @@ public class StatisticMgmtService {
...
@@ -167,10 +141,6 @@ public class StatisticMgmtService {
LOGGER
.
log
(
Level
.
ERROR
,
"Updates blog view count failed"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Updates blog view count failed"
,
e
);
}
}
}
else
{
// Repository cache prefix, Refers to GAERepository#CACHE_KEY_PREFIX
statisticRepository
.
getCache
().
putAsync
(
REPOSITORY_CACHE_KEY_PREFIX
+
Statistic
.
STATISTIC
,
statistic
);
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Inced blog view count[statistic={0}]"
,
statistic
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Inced blog view count[statistic={0}]"
,
statistic
);
}
}
...
@@ -379,98 +349,6 @@ public class StatisticMgmtService {
...
@@ -379,98 +349,6 @@ public class StatisticMgmtService {
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{0}]"
,
ONLINE_VISITORS
.
size
());
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{0}]"
,
ONLINE_VISITORS
.
size
());
}
}
/**
* Flushes the statistic to repository.
*
* @throws ServiceException
*/
public
void
flushStatistic
()
throws
ServiceException
{
if
(!
Latkes
.
isDataCacheEnabled
())
{
return
;
}
final
JSONObject
statistic
=
(
JSONObject
)
statisticRepository
.
getCache
().
get
(
REPOSITORY_CACHE_KEY_PREFIX
+
Statistic
.
STATISTIC
);
if
(
null
==
statistic
)
{
LOGGER
.
log
(
Level
.
INFO
,
"Not found statistic in cache, ignores sync"
);
return
;
}
final
Transaction
transaction
=
statisticRepository
.
beginTransaction
();
transaction
.
clearQueryCache
(
false
);
try
{
statisticRepository
.
getCache
().
remove
(
REPOSITORY_CACHE_KEY_PREFIX
+
Statistic
.
STATISTIC
);
// For blog view counter
statisticRepository
.
update
(
Statistic
.
STATISTIC
,
statistic
);
// For article view counter
final
Set
<
String
>
keys
=
pageCaches
.
getKeys
();
final
List
<
String
>
keyList
=
new
ArrayList
<
String
>(
keys
);
final
int
size
=
keys
.
size
()
>
FLUSH_SIZE
?
FLUSH_SIZE
:
keys
.
size
();
// Flush FLUSH_SIZE articles at most
final
List
<
Integer
>
idx
=
CollectionUtils
.
getRandomIntegers
(
0
,
keys
.
size
(),
size
);
final
Set
<
String
>
cachedPageKeys
=
new
HashSet
<
String
>();
for
(
final
Integer
i
:
idx
)
{
cachedPageKeys
.
add
(
keyList
.
get
(
i
));
}
for
(
final
String
cachedPageKey
:
cachedPageKeys
)
{
final
JSONObject
cachedPage
=
PageCaches
.
get
(
cachedPageKey
);
if
(
null
==
cachedPage
)
{
continue
;
}
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
if
(!
cachedPage
.
optString
(
PageCaches
.
CACHED_TYPE
).
equals
(
langs
.
get
(
PageTypes
.
ARTICLE
.
getLangeLabel
())))
{
// Cached is not an article page
continue
;
}
final
int
hitCount
=
cachedPage
.
optInt
(
PageCaches
.
CACHED_HIT_COUNT
);
final
String
articleId
=
cachedPage
.
optString
(
PageCaches
.
CACHED_OID
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
if
(
null
==
article
)
{
continue
;
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Updating article[id={0}, title={1}] view count"
,
new
Object
[]
{
articleId
,
cachedPage
.
optString
(
PageCaches
.
CACHED_TITLE
)});
final
int
oldViewCount
=
article
.
optInt
(
Article
.
ARTICLE_VIEW_COUNT
);
final
int
viewCount
=
oldViewCount
+
hitCount
;
article
.
put
(
Article
.
ARTICLE_VIEW_COUNT
,
viewCount
);
article
.
put
(
Article
.
ARTICLE_RANDOM_DOUBLE
,
Math
.
random
());
// Updates random value
articleRepository
.
update
(
articleId
,
article
);
cachedPage
.
put
(
PageCaches
.
CACHED_HIT_COUNT
,
0
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Updating article[id={0}, title={1}] view count from [{2}] to [{3}]"
,
new
Object
[]
{
articleId
,
article
.
optString
(
Article
.
ARTICLE_TITLE
),
oldViewCount
,
viewCount
});
}
transaction
.
commit
();
LOGGER
.
log
(
Level
.
INFO
,
"Synchronized statistic from cache to repository[statistic={0}]"
,
statistic
);
}
catch
(
final
RepositoryException
e
)
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
}
LOGGER
.
log
(
Level
.
ERROR
,
"Updates statistic failed"
,
e
);
}
}
/**
/**
* Updates the statistic with the specified statistic.
* Updates the statistic with the specified statistic.
*
*
...
...
core/src/test/resources/latke.properties
View file @
31a5d8b5
...
@@ -51,9 +51,5 @@ cache=GAE
...
@@ -51,9 +51,5 @@ cache=GAE
# userService=GAE
# userService=GAE
userService
=
LOCAL
userService
=
LOCAL
#### Cache ####
cache.maxPageCnt
=
128
cache.maxDataCnt
=
128
#### Static resource version ####
#### Static resource version ####
staticResourceVersion
=
201206280945
staticResourceVersion
=
201206280945
\ No newline at end of file
war/bae/src/main/resources/latke.properties
View file @
31a5d8b5
...
@@ -52,9 +52,5 @@ cache=BAE
...
@@ -52,9 +52,5 @@ cache=BAE
#### User Service Implementation ####
#### User Service Implementation ####
userService
=
LOCAL
userService
=
LOCAL
#### Cache ####
cache.maxPageCnt
=
0
cache.maxDataCnt
=
0
#### Static resource version ####
#### Static resource version ####
staticResourceVersion
=
201308241630
staticResourceVersion
=
201308241630
\ No newline at end of file
war/gae/src/main/resources/latke.properties
View file @
31a5d8b5
...
@@ -51,9 +51,5 @@ cache=GAE
...
@@ -51,9 +51,5 @@ cache=GAE
#### User Service Implementation ####
#### User Service Implementation ####
userService
=
LOCAL
userService
=
LOCAL
#### Cache ####
cache.maxPageCnt
=
1024000
cache.maxDataCnt
=
1024000
#### Static resource version ####
#### Static resource version ####
staticResourceVersion
=
201308241630
staticResourceVersion
=
201308241630
\ No newline at end of file
war/h2/src/main/resources/latke.properties
View file @
31a5d8b5
...
@@ -51,9 +51,5 @@ cache=LOCAL
...
@@ -51,9 +51,5 @@ cache=LOCAL
#### User Service Implementation ####
#### User Service Implementation ####
userService
=
LOCAL
userService
=
LOCAL
#### Cache ####
cache.maxPageCnt
=
128
cache.maxDataCnt
=
128
#### Static resource version ####
#### Static resource version ####
staticResourceVersion
=
201308241630
staticResourceVersion
=
201308241630
\ No newline at end of file
war/mysql/src/main/resources/latke.properties
View file @
31a5d8b5
...
@@ -51,9 +51,5 @@ cache=LOCAL
...
@@ -51,9 +51,5 @@ cache=LOCAL
#### User Service Implementation ####
#### User Service Implementation ####
userService
=
LOCAL
userService
=
LOCAL
#### Cache ####
cache.maxPageCnt
=
128
cache.maxDataCnt
=
128
#### Static resource version ####
#### Static resource version ####
staticResourceVersion
=
201308241630
staticResourceVersion
=
201308241630
\ No newline at end of file
war/src/main/resources/lang_en_US.properties
View file @
31a5d8b5
...
@@ -231,8 +231,6 @@ tagsLabel=Tags
...
@@ -231,8 +231,6 @@ tagsLabel=Tags
importedLabel
=
Imported
importedLabel
=
Imported
captcha1Label
=
Captcha:
captcha1Label
=
Captcha:
captchaLabel
=
Captcha
captchaLabel
=
Captcha
clearAllCacheLabel
=
Clear all cache
clearCacheLabel
=
Clear cache
indexLabel
=
Index
indexLabel
=
Index
nextArticle1Label
=
Next:
nextArticle1Label
=
Next:
previousArticle1Label
=
Previous:
previousArticle1Label
=
Previous:
...
...
war/src/main/resources/lang_zh_CN.properties
View file @
31a5d8b5
...
@@ -231,8 +231,6 @@ tagsLabel=\u6807\u7b7e
...
@@ -231,8 +231,6 @@ tagsLabel=\u6807\u7b7e
importedLabel
=
\u
5df2
\u
5bfc
\u5165
importedLabel
=
\u
5df2
\u
5bfc
\u5165
captcha1Label
=
\u
9a8c
\u
8bc1
\u7801\u
ff1a
captcha1Label
=
\u
9a8c
\u
8bc1
\u7801\u
ff1a
captchaLabel
=
\u
9a8c
\u
8bc1
\u7801
captchaLabel
=
\u
9a8c
\u
8bc1
\u7801
clearAllCacheLabel
=
\u
6e05
\u9664\u6240\u6709\u9875\u9762\u
7f13
\u
5b58
clearCacheLabel
=
\u
6e05
\u9664\u
672c
\u9875\u
7f13
\u
5b58
indexLabel
=
\u9996\u9875
indexLabel
=
\u9996\u9875
nextArticle1Label
=
\u
65b0
\u
4e00
\u
7bc7
\u
ff1a
nextArticle1Label
=
\u
65b0
\u
4e00
\u
7bc7
\u
ff1a
previousArticle1Label
=
\u
65e7
\u
4e00
\u
7bc7
\u
ff1a
previousArticle1Label
=
\u
65e7
\u
4e00
\u
7bc7
\u
ff1a
...
...
war/src/main/webapp/WEB-INF/cron.xml
View file @
31a5d8b5
...
@@ -31,12 +31,6 @@
...
@@ -31,12 +31,6 @@
<schedule>
every 5 minutes
</schedule>
<schedule>
every 5 minutes
</schedule>
</cron>
</cron>
<cron>
<url>
/console/stat/viewcnt
</url>
<description>
Async Blog/Article counter
</description>
<schedule>
every 30 minutes
</schedule>
</cron>
<cron>
<cron>
<url>
/console/stat/onlineVisitorRefresh
</url>
<url>
/console/stat/onlineVisitorRefresh
</url>
<description>
Online Visitor Refresher
</description>
<description>
Online Visitor Refresher
</description>
...
...
war/src/main/webapp/WEB-INF/web.xml
View file @
31a5d8b5
...
@@ -65,14 +65,6 @@
...
@@ -65,14 +65,6 @@
<url-pattern>
/rm-all-data.do
</url-pattern>
<url-pattern>
/rm-all-data.do
</url-pattern>
<url-pattern>
/fix/*
</url-pattern>
<url-pattern>
/fix/*
</url-pattern>
</filter-mapping>
</filter-mapping>
<filter>
<filter-name>
PageCacheFilter
</filter-name>
<filter-class>
org.b3log.solo.filter.PageCacheFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>
PageCacheFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<filter>
<filter>
<filter-name>
PermalinkFilter
</filter-name>
<filter-name>
PermalinkFilter
</filter-name>
<filter-class>
org.b3log.solo.filter.PermalinkFilter
</filter-class>
<filter-class>
org.b3log.solo.filter.PermalinkFilter
</filter-class>
...
...
war/src/main/webapp/js/admin/latkeAdmin.js
View file @
31a5d8b5
...
@@ -889,7 +889,7 @@ admin.article = {
...
@@ -889,7 +889,7 @@ admin.article = {
// 自动保存草稿定时器
// 自动保存草稿定时器
autoSaveDraftTimer
:
""
,
autoSaveDraftTimer
:
""
,
// 自动保存间隔
// 自动保存间隔
AUTOSAVETIME
:
1000
*
6
,
AUTOSAVETIME
:
1000
*
6
0
,
/**
/**
* @description 获取文章并把值塞入发布文章页面
* @description 获取文章并把值塞入发布文章页面
* @param {String} id 文章 id
* @param {String} id 文章 id
...
...
war/src/main/webapp/js/admin/latkeAdmin.min.js
View file @
31a5d8b5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
war/src/main/webapp/js/common.js
View file @
31a5d8b5
...
@@ -155,28 +155,6 @@ var Util = {
...
@@ -155,28 +155,6 @@ var Util = {
Util
.
killIE
();
Util
.
killIE
();
Util
.
setTopBar
();
Util
.
setTopBar
();
},
},
/**
* @description topbar 清除缓存按钮事件
*/
clearCache
:
function
(
all
)
{
var
data
=
''
;
if
(
all
===
"
all
"
)
{
data
=
'
{"all": "all", "URI": ""}
'
;
}
else
{
data
=
'
{"all": "all", "URI": "
'
+
window
.
location
.
pathname
+
'
"}
'
;
}
$
.
ajax
({
type
:
"
POST
"
,
url
:
latkeConfig
.
servePath
+
"
/clear-cache.do
"
,
cache
:
false
,
contentType
:
"
application/json
"
,
data
:
data
,
success
:
function
(
result
)
{
window
.
location
.
reload
();
}
});
},
/**
/**
* @description 替换侧边栏表情为图片
* @description 替换侧边栏表情为图片
* @param {Dom} comments 评论内容元素
* @param {Dom} comments 评论内容元素
...
...
war/src/main/webapp/js/common.min.js
View file @
31a5d8b5
...
@@ -13,4 +13,4 @@
...
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
var
Util
=
{
error
:
function
(){
$
(
"
#tipMsg
"
).
text
(
"
Error:
"
+
arguments
[
0
]
+
"
File:
"
+
arguments
[
1
]
+
"
\n
Line:
"
+
arguments
[
2
]
+
"
please report this issue on https://github.com/b3log/b3log-solo/issues/new
"
);
$
(
"
#loadMsg
"
).
text
(
""
)},
killIE
:
function
(){
var
addKillPanel
=
function
(){
if
(
Cookie
.
readCookie
(
"
showKill
"
)
===
""
){
var
left
=
(
$
(
window
).
width
()
-
701
)
/
2
,
top
=
(
$
(
window
).
height
()
-
420
)
/
2
;
$
(
"
body
"
).
append
(
"
<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6; top: 0px;z-index:11'></div><iframe style='left:
"
+
left
+
"
px;z-index:20;top:
"
+
top
+
"
px; position: fixed; border: 0px none; width: 701px; height: 420px;' src='
"
+
latkeConfig
.
servePath
+
"
/kill-browser.html'></iframe>
"
)}};
if
(
$
.
browser
.
msie
){
if
(
$
.
browser
.
version
===
"
6.0
"
||
$
.
browser
.
version
===
"
7.0
"
){
addKillPanel
();
return
}
if
(
window
.
external
&&
window
.
external
.
twGetRunPath
){
var
path
=
external
.
twGetRunPath
();
if
(
path
&&
path
.
toLowerCase
().
indexOf
(
"
360se
"
)
>-
1
&&
window
.
location
.
href
.
indexOf
(
"
admin-index
"
)
>-
1
){
addKillPanel
();
return
}}}},
replaceEmString
:
function
(
str
){
var
commentSplited
=
str
.
split
(
"
[em
"
);
if
(
commentSplited
.
length
===
1
){
return
str
}
str
=
commentSplited
[
0
];
for
(
var
j
=
1
;
j
<
commentSplited
.
length
;
j
++
){
var
key
=
commentSplited
[
j
].
substr
(
0
,
2
);
str
+=
"
<img src='
"
+
latkeConfig
.
staticServePath
+
"
/skins/
"
+
Label
.
skinDirName
+
"
/images/emotions/em
"
+
key
+
"
.png' alt='
"
+
Label
[
"
em
"
+
key
+
"
Label
"
]
+
"
' title='
"
+
Label
[
"
em
"
+
key
+
"
Label
"
]
+
"
'/>
"
+
commentSplited
[
j
].
substr
(
3
)}
return
str
},
proessURL
:
function
(
url
){
if
(
!
/^
\w
+:
\/\/
/
.
test
(
url
)){
url
=
"
http://
"
+
url
}
return
url
},
switchMobile
:
function
(
skin
){
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
setTimeout
(
function
(){
location
.
reload
()},
1250
)},
setTopBar
:
function
(){
var
$top
=
$
(
"
#top
"
);
if
(
$top
.
length
===
1
){
var
$showTop
=
$
(
"
#showTop
"
);
$showTop
.
click
(
function
(){
$top
.
slideDown
();
$showTop
.
hide
()});
$
(
"
#hideTop
"
).
click
(
function
(){
$top
.
slideUp
();
$showTop
.
show
()})}},
goTop
:
function
(){
var
acceleration
=
acceleration
||
0.1
;
var
y
=
$
(
window
).
scrollTop
();
var
speed
=
1
+
acceleration
;
window
.
scrollTo
(
0
,
Math
.
floor
(
y
/
speed
));
if
(
y
>
0
){
var
invokeFunction
=
"
Util.goTop(
"
+
acceleration
+
"
)
"
;
window
.
setTimeout
(
invokeFunction
,
16
)}},
goBottom
:
function
(
bottom
){
if
(
!
bottom
){
bottom
=
0
}
window
.
scrollTo
(
0
,
$
(
"
body
"
).
height
()
-
$
(
window
).
height
()
-
bottom
)},
init
:
function
(){
Util
.
killIE
();
Util
.
setTopBar
()},
clearCache
:
function
(
all
){
var
data
=
""
;
if
(
all
===
"
all
"
){
data
=
'
{"all": "all", "URI": ""}
'
}
else
{
data
=
'
{"all": "all", "URI": "
'
+
window
.
location
.
pathname
+
'
"}
'
}
$
.
ajax
({
type
:
"
POST
"
,
url
:
latkeConfig
.
servePath
+
"
/clear-cache.do
"
,
cache
:
false
,
contentType
:
"
application/json
"
,
data
:
data
,
success
:
function
(
result
){
window
.
location
.
reload
()}})},
replaceSideEm
:
function
(
comments
){
for
(
var
i
=
0
;
i
<
comments
.
length
;
i
++
){
var
$comment
=
$
(
comments
[
i
]);
$comment
.
html
(
Util
.
replaceEmString
(
$comment
.
html
()))}},
buildTags
:
function
(
id
){
id
=
id
||
"
tags
"
;
var
classes
=
[
"
tags1
"
,
"
tags2
"
,
"
tags3
"
,
"
tags4
"
,
"
tags5
"
],
bList
=
$
(
"
#
"
+
id
+
"
b
"
).
get
();
var
max
=
parseInt
(
$
(
"
#
"
+
id
+
"
b
"
).
last
().
text
());
var
distance
=
Math
.
ceil
(
max
/
classes
.
length
);
for
(
var
i
=
0
;
i
<
bList
.
length
;
i
++
){
var
num
=
parseInt
(
bList
[
i
].
innerHTML
);
for
(
var
j
=
0
;
j
<
classes
.
length
;
j
++
){
if
(
num
>
j
*
distance
&&
num
<=
(
j
+
1
)
*
distance
){
bList
[
i
].
parentNode
.
className
=
classes
[
j
];
break
}}}
$
(
"
#
"
+
id
).
html
(
$
(
"
#
"
+
id
+
"
li
"
).
get
().
sort
(
function
(
a
,
b
){
var
valA
=
$
(
a
).
find
(
"
span
"
).
text
().
toLowerCase
();
var
valB
=
$
(
b
).
find
(
"
span
"
).
text
().
toLowerCase
();
return
valA
.
localeCompare
(
valB
)}))},
toDate
:
function
(
time
,
format
){
var
dateTime
=
new
Date
(
time
);
var
o
=
{
"
M+
"
:
dateTime
.
getMonth
()
+
1
,
"
d+
"
:
dateTime
.
getDate
(),
"
H+
"
:
dateTime
.
getHours
(),
"
m+
"
:
dateTime
.
getMinutes
(),
"
s+
"
:
dateTime
.
getSeconds
(),
"
q+
"
:
Math
.
floor
((
dateTime
.
getMonth
()
+
3
)
/
3
),
S
:
dateTime
.
getMilliseconds
()};
if
(
/
(
y+
)
/
.
test
(
format
)){
format
=
format
.
replace
(
RegExp
.
$1
,(
dateTime
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
))}
for
(
var
k
in
o
){
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
format
)){
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
1
?
o
[
k
]:(
"
00
"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
))}}
return
format
},
getWinHeight
:
function
(){
if
(
window
.
innerHeight
){
return
window
.
innerHeight
}
if
(
document
.
compatMode
===
"
CSS1Compat
"
){
return
window
.
document
.
documentElement
.
clientHeight
}
return
window
.
document
.
body
.
clientHeight
}};
if
(
!
Cookie
){
var
Cookie
=
{
readCookie
:
function
(
name
){
var
nameEQ
=
name
+
"
=
"
;
var
ca
=
document
.
cookie
.
split
(
"
;
"
);
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
){
var
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
"
"
){
c
=
c
.
substring
(
1
,
c
.
length
)}
if
(
c
.
indexOf
(
nameEQ
)
==
0
){
return
decodeURIComponent
(
c
.
substring
(
nameEQ
.
length
,
c
.
length
))}}
return
""
},
eraseCookie
:
function
(
name
){
this
.
createCookie
(
name
,
""
,
-
1
)},
createCookie
:
function
(
name
,
value
,
days
){
var
expires
=
""
;
if
(
days
){
var
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
(
days
*
24
*
60
*
60
*
1000
));
expires
=
"
; expires=
"
+
date
.
toGMTString
()}
document
.
cookie
=
name
+
"
=
"
+
encodeURIComponent
(
value
)
+
expires
+
"
; path=/
"
}}};
var
Util
=
{
error
:
function
(){
$
(
"
#tipMsg
"
).
text
(
"
Error:
"
+
arguments
[
0
]
+
"
File:
"
+
arguments
[
1
]
+
"
\n
Line:
"
+
arguments
[
2
]
+
"
please report this issue on https://github.com/b3log/b3log-solo/issues/new
"
);
$
(
"
#loadMsg
"
).
text
(
""
)},
killIE
:
function
(){
var
addKillPanel
=
function
(){
if
(
Cookie
.
readCookie
(
"
showKill
"
)
===
""
){
var
left
=
(
$
(
window
).
width
()
-
701
)
/
2
,
top
=
(
$
(
window
).
height
()
-
420
)
/
2
;
$
(
"
body
"
).
append
(
"
<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6; top: 0px;z-index:11'></div><iframe style='left:
"
+
left
+
"
px;z-index:20;top:
"
+
top
+
"
px; position: fixed; border: 0px none; width: 701px; height: 420px;' src='
"
+
latkeConfig
.
servePath
+
"
/kill-browser.html'></iframe>
"
)}};
if
(
$
.
browser
.
msie
){
if
(
$
.
browser
.
version
===
"
6.0
"
||
$
.
browser
.
version
===
"
7.0
"
){
addKillPanel
();
return
}
if
(
window
.
external
&&
window
.
external
.
twGetRunPath
){
var
path
=
external
.
twGetRunPath
();
if
(
path
&&
path
.
toLowerCase
().
indexOf
(
"
360se
"
)
>-
1
&&
window
.
location
.
href
.
indexOf
(
"
admin-index
"
)
>-
1
){
addKillPanel
();
return
}}}},
replaceEmString
:
function
(
str
){
var
commentSplited
=
str
.
split
(
"
[em
"
);
if
(
commentSplited
.
length
===
1
){
return
str
}
str
=
commentSplited
[
0
];
for
(
var
j
=
1
;
j
<
commentSplited
.
length
;
j
++
){
var
key
=
commentSplited
[
j
].
substr
(
0
,
2
);
str
+=
"
<img src='
"
+
latkeConfig
.
staticServePath
+
"
/skins/
"
+
Label
.
skinDirName
+
"
/images/emotions/em
"
+
key
+
"
.png' alt='
"
+
Label
[
"
em
"
+
key
+
"
Label
"
]
+
"
' title='
"
+
Label
[
"
em
"
+
key
+
"
Label
"
]
+
"
'/>
"
+
commentSplited
[
j
].
substr
(
3
)}
return
str
},
proessURL
:
function
(
url
){
if
(
!
/^
\w
+:
\/\/
/
.
test
(
url
)){
url
=
"
http://
"
+
url
}
return
url
},
switchMobile
:
function
(
skin
){
Cookie
.
createCookie
(
"
btouch_switch_toggle
"
,
skin
,
365
);
setTimeout
(
function
(){
location
.
reload
()},
1250
)},
setTopBar
:
function
(){
var
$top
=
$
(
"
#top
"
);
if
(
$top
.
length
===
1
){
var
$showTop
=
$
(
"
#showTop
"
);
$showTop
.
click
(
function
(){
$top
.
slideDown
();
$showTop
.
hide
()});
$
(
"
#hideTop
"
).
click
(
function
(){
$top
.
slideUp
();
$showTop
.
show
()})}},
goTop
:
function
(){
var
acceleration
=
acceleration
||
0.1
;
var
y
=
$
(
window
).
scrollTop
();
var
speed
=
1
+
acceleration
;
window
.
scrollTo
(
0
,
Math
.
floor
(
y
/
speed
));
if
(
y
>
0
){
var
invokeFunction
=
"
Util.goTop(
"
+
acceleration
+
"
)
"
;
window
.
setTimeout
(
invokeFunction
,
16
)}},
goBottom
:
function
(
bottom
){
if
(
!
bottom
){
bottom
=
0
}
window
.
scrollTo
(
0
,
$
(
"
body
"
).
height
()
-
$
(
window
).
height
()
-
bottom
)},
init
:
function
(){
Util
.
killIE
();
Util
.
setTopBar
()},
replaceSideEm
:
function
(
comments
){
for
(
var
i
=
0
;
i
<
comments
.
length
;
i
++
){
var
$comment
=
$
(
comments
[
i
]);
$comment
.
html
(
Util
.
replaceEmString
(
$comment
.
html
()))}},
buildTags
:
function
(
id
){
id
=
id
||
"
tags
"
;
var
classes
=
[
"
tags1
"
,
"
tags2
"
,
"
tags3
"
,
"
tags4
"
,
"
tags5
"
],
bList
=
$
(
"
#
"
+
id
+
"
b
"
).
get
();
var
max
=
parseInt
(
$
(
"
#
"
+
id
+
"
b
"
).
last
().
text
());
var
distance
=
Math
.
ceil
(
max
/
classes
.
length
);
for
(
var
i
=
0
;
i
<
bList
.
length
;
i
++
){
var
num
=
parseInt
(
bList
[
i
].
innerHTML
);
for
(
var
j
=
0
;
j
<
classes
.
length
;
j
++
){
if
(
num
>
j
*
distance
&&
num
<=
(
j
+
1
)
*
distance
){
bList
[
i
].
parentNode
.
className
=
classes
[
j
];
break
}}}
$
(
"
#
"
+
id
).
html
(
$
(
"
#
"
+
id
+
"
li
"
).
get
().
sort
(
function
(
a
,
b
){
var
valA
=
$
(
a
).
find
(
"
span
"
).
text
().
toLowerCase
();
var
valB
=
$
(
b
).
find
(
"
span
"
).
text
().
toLowerCase
();
return
valA
.
localeCompare
(
valB
)}))},
toDate
:
function
(
time
,
format
){
var
dateTime
=
new
Date
(
time
);
var
o
=
{
"
M+
"
:
dateTime
.
getMonth
()
+
1
,
"
d+
"
:
dateTime
.
getDate
(),
"
H+
"
:
dateTime
.
getHours
(),
"
m+
"
:
dateTime
.
getMinutes
(),
"
s+
"
:
dateTime
.
getSeconds
(),
"
q+
"
:
Math
.
floor
((
dateTime
.
getMonth
()
+
3
)
/
3
),
S
:
dateTime
.
getMilliseconds
()};
if
(
/
(
y+
)
/
.
test
(
format
)){
format
=
format
.
replace
(
RegExp
.
$1
,(
dateTime
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
))}
for
(
var
k
in
o
){
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
format
)){
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
1
?
o
[
k
]:(
"
00
"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
))}}
return
format
},
getWinHeight
:
function
(){
if
(
window
.
innerHeight
){
return
window
.
innerHeight
}
if
(
document
.
compatMode
===
"
CSS1Compat
"
){
return
window
.
document
.
documentElement
.
clientHeight
}
return
window
.
document
.
body
.
clientHeight
}};
if
(
!
Cookie
){
var
Cookie
=
{
readCookie
:
function
(
name
){
var
nameEQ
=
name
+
"
=
"
;
var
ca
=
document
.
cookie
.
split
(
"
;
"
);
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
){
var
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
"
"
){
c
=
c
.
substring
(
1
,
c
.
length
)}
if
(
c
.
indexOf
(
nameEQ
)
==
0
){
return
decodeURIComponent
(
c
.
substring
(
nameEQ
.
length
,
c
.
length
))}}
return
""
},
eraseCookie
:
function
(
name
){
this
.
createCookie
(
name
,
""
,
-
1
)},
createCookie
:
function
(
name
,
value
,
days
){
var
expires
=
""
;
if
(
days
){
var
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
(
days
*
24
*
60
*
60
*
1000
));
expires
=
"
; expires=
"
+
date
.
toGMTString
()}
document
.
cookie
=
name
+
"
=
"
+
encodeURIComponent
(
value
)
+
expires
+
"
; path=/
"
}}};
\ No newline at end of file
\ No newline at end of file
war/src/main/webapp/plugins/admin-cache/lang_en_US.properties
deleted
100644 → 0
View file @
6db5b6e3
#
# Copyright (c) 2009, 2010, 2011, 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.
#
#
# Description: Language configurations(en_US) of plugin admin-cache.
# Version: 1.0.0.3, Jun 25, 2011
# Author: Liyuan Li
# Author: Liang Ding
#
cacheMgmtLabel
=
Cache
typeLabel
=
Type
hitCountLabel
=
Hit Count
pageCacheStatus1Label
=
Page Cache Status:
pageCachedCnt1Label
=
Cached Page Count:
cachedCount1Label
=
Cached Count:
hitCount1Label
=
Hit Count:
cachedBytes1Label
=
Cached Bytes:
hitBytes1Label
=
Hit Bytes:
missCount1Label
=
Miss Count:
\ No newline at end of file
war/src/main/webapp/plugins/admin-cache/lang_zh_CN.properties
deleted
100644 → 0
View file @
6db5b6e3
#
# Copyright (c) 2009, 2010, 2011, 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.
#
#
# Description: Language configurations(zh_CN) of plugin admin-cache.
# Version: 1.0.0.4, Jun 26, 2011
# Author: Liyuan Li
# Author: Liang Ding
#
cacheMgmtLabel
=
\u
7f13
\u
5b58
\u
7ba1
\u7406
typeLabel=
\u
7c7b
\u
578b
hitCountLabel
=
\u
547d
\u
4e2d
\u
6b21
\u6570
pageCacheStatus1Label=
\u9875\u9762\u
7f13
\u
5b58
\u
72b6
\u6001\u
ff1a
pageCachedCnt1Label
=
\u
5df2
\u
7f13
\u
5b58
\u9875\u9762\u6570\u
ff1a
cachedCount1Label
=
\u
5f53
\u
524d
\u
7f13
\u
5b58
\u6570\u
ff1a
hitCount1Label
=
\u
547d
\u
4e2d
\u
6b21
\u6570\u
ff1a
cachedBytes1Label
=
\u
5df2
\u
7f13
\u
5b58
\u
5b57
\u8282\u
ff1a
hitBytes1Label
=
\u
5df2
\u
547d
\u
4e2d
\u
5b57
\u8282\u
ff1a
missCount1Label
=
\u
4e22
\u5931\u
6b21
\u6570\u
ff1a
\ No newline at end of file
war/src/main/webapp/plugins/admin-cache/plugin.ftl
deleted
100644 → 0
View file @
6db5b6e3
<style type="text/css">
#cacheContent {
line-height: 28px;
padding: 12px;
}
</style>
<div id="cachePlugin">
<div id="cacheContent"></div>
<div id="cacheTable"></div>
<div id="cachePagination" class="margin12 right"></div>
<div class="clear"></div>
</div>
<script type="text/javascript">
plugins["cache-list"] = {
tablePagination: new TablePaginate("cache"),
getList: function (pageNum) {
var that = this;
$("#loadMsg").text("${loadingLabel}");
$.ajax({
url: latkeConfig.servePath + "/console/plugins/admin-cache/pages/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET",
cache: false,
success: function(result, textStatus){
if (!result.sc) {
$("#tipMsg").text(result.msg);
return;
}
var caches = result.pages;
var cacheData = caches;
for (var i = 0; i < caches.length; i++) {
cacheData[i].cachedTitle = "<a href='" + caches[i].cachedLink + "' target='_blank'>"
+ caches[i].cachedTitle + "</a>";
cacheData[i].cachedTime = $.bowknot.getDate(cacheData[i].cachedTime, 1);
}
that.tablePagination.updateTablePagination(cacheData, pageNum, result.pagination);
$("#loadMsg").text("");
}
});
},
changeStatus: function (it) {
$("#loadMsg").text("${loadingLabel}");
var $it = $(it);
var flag = "true";
if ($it.text() === "${enabledLabel}") {
flag = "false";
}
$.ajax({
url: latkeConfig.servePath + "/console/plugins/admin-cache/enable/" + flag,
type: "PUT",
cache: false,
success: function(result, textStatus){
if (!result.sc) {
$("#tipMsg").text(result.msg);
return;
}
if ($it.text() === "${enabledLabel}") {
$it.text("${disabledLabel}");
} else {
$it.text("${enabledLabel}");
}
$("#tipMsg").text("${updateSuccLabel}");
$("#loadMsg").text("");
}
});
},
getCache: function () {
$("#loadMsg").text("${loadingLabel}");
$.ajax({
url: latkeConfig.servePath + "/console/plugins/admin-cache/status/",
type: "GET",
cache: false,
success: function(result, textStatus){
if (!result.sc) {
$("#tipMsg").text(result.msg);
return;
}
var pageCacheStatusLabel = "${disabledLabel}";
if (result.pageCacheEnabled) {
pageCacheStatusLabel = "${enabledLabel}";
}
var cacheHTML = "${pageCacheStatus1Label} <button onclick=\"window.plugins['cache-list'].changeStatus(this);\">"
+ pageCacheStatusLabel
+ "</button> ${pageCachedCnt1Label}<span class='f-blue'>" + result.pageCachedCnt;
$("#cacheContent").html(cacheHTML);
$("#loadMsg").text("");
}
});
},
init: function (page) {
this.tablePagination.buildTable([{
style: "padding-left: 6px;",
text: "${typeLabel}",
index: "cachedType",
width: 220
}, {
style: "padding-left: 6px;",
text: "${titleLabel}",
index: "cachedTitle",
minWidth: 300
}, {
style: "padding-left: 6px;",
text: "${hitCountLabel}",
index: "cachedHitCount",
width: 120
}, {
style: "padding-left: 6px;",
text: "${sizeLabel}(Byte)",
index: "cachedBtypesLength",
width: 120
}, {
style: "padding-left: 6px;",
text: "${createDateLabel}",
index: "cachedTime",
width: 160
}]);
this.tablePagination.initPagination();
this.getList(page);
this.getCache();
},
refresh: function (page) {
this.getList(page);
this.getCache();
}
};
/*
* 添加插件
*/
admin.plugin.add({
"id": "cache-list",
"text": "${cacheMgmtLabel}",
"path": "/tools",
"index": 6,
"content": $("#cachePlugin").html()
});
// 移除现有内容
$("#cachePlugin").remove();
</script>
\ No newline at end of file
war/src/main/webapp/plugins/admin-cache/plugin.properties
deleted
100644 → 0
View file @
6db5b6e3
#
# Copyright (c) 2009, 2010, 2011, 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.
#
#
# Description: Description of plugin admin-cache.
# Version: 1.0.1.0, May 16, 2012
# Author: Liang Ding
#
rendererId
=
admin-index.ftl
author
=
<a href="http://88250.b3log.org">88250</a> & <a href="http://vanessa.b3log.org">Vanessa</a>
name
=
Admin Cache
version
=
0.1.2
types
=
ADMIN
classesDirPath
=
/WEB-INF/classes/
# TODO: libDirPath=/WEB-INF/lib/
pluginClass
=
eventListenerClasses=
\ No newline at end of file
war/src/main/webapp/skins/ease/footer.ftl
View file @
31a5d8b5
...
@@ -47,8 +47,6 @@
...
@@ -47,8 +47,6 @@
"updatedLabel": "${updatedLabel}",
"updatedLabel": "${updatedLabel}",
"contentLabel": "${contentLabel}",
"contentLabel": "${contentLabel}",
"abstractLabel": "${abstractLabel}",
"abstractLabel": "${abstractLabel}",
"clearAllCacheLabel": "${clearAllCacheLabel}",
"clearCacheLabel": "${clearCacheLabel}",
"adminLabel": "${adminLabel}",
"adminLabel": "${adminLabel}",
"logoutLabel": "${logoutLabel}",
"logoutLabel": "${logoutLabel}",
"skinDirName": "${skinDirName}",
"skinDirName": "${skinDirName}",
...
...
war/src/main/webapp/skins/ease/lang/lang_en_US.properties
View file @
31a5d8b5
...
@@ -39,8 +39,6 @@ linkLabel=Friend Links
...
@@ -39,8 +39,6 @@ linkLabel=Friend Links
indexLabel
=
Home
indexLabel
=
Home
sumLabel
=
sumLabel
=
pageLabel=Page
pageLabel=Page
clearAllCacheLabel
=
Clear all cache
clearCacheLabel
=
Clear cache
adminLabel
=
Admin
adminLabel
=
Admin
logoutLabel
=
Logout
logoutLabel
=
Logout
loginLabel
=
Login
loginLabel
=
Login
...
...
war/src/main/webapp/skins/ease/lang/lang_zh_CN.properties
View file @
31a5d8b5
...
@@ -41,8 +41,6 @@ linkLabel=\u53cb\u60c5\u94fe\u63a5
...
@@ -41,8 +41,6 @@ linkLabel=\u53cb\u60c5\u94fe\u63a5
indexLabel
=
\u9996\u9875
indexLabel
=
\u9996\u9875
sumLabel=
\u5171
sumLabel=
\u5171
pageLabel=
\u9875
pageLabel=
\u9875
clearAllCacheLabel=
\u
6e05
\u9664\u6240\u6709\u9875\u9762\u
7f13
\u
5b58
clearCacheLabel
=
\u
6e05
\u9664\u
672c
\u9875\u
7f13
\u
5b58
adminLabel=
\u
7ba1
\u7406
adminLabel=
\u
7ba1
\u7406
logoutLabel=
\u
767b
\u
51fa
logoutLabel=
\u
767b
\u
51fa
loginLabel
=
\u
767b
\u
5f55
loginLabel
=
\u
767b
\u
5f55
...
...
war/src/main/webapp/skins/mobile/lang/lang_en_US.properties
View file @
31a5d8b5
...
@@ -164,8 +164,6 @@ tagsLabel=Tags
...
@@ -164,8 +164,6 @@ tagsLabel=Tags
importedLabel
=
Imported
importedLabel
=
Imported
captcha1Label
=
Captcha:
captcha1Label
=
Captcha:
captchaLabel
=
Captcha
captchaLabel
=
Captcha
clearAllCacheLabel
=
Clear all cache
clearCacheLabel
=
Clear cache
indexLabel
=
Index
indexLabel
=
Index
nextArticle1Label
=
Next:
nextArticle1Label
=
Next:
previousArticle1Label
=
Previous:
previousArticle1Label
=
Previous:
...
...
war/src/main/webapp/skins/mobile/lang/lang_zh_CN.properties
View file @
31a5d8b5
...
@@ -170,8 +170,6 @@ tagsLabel=\u6807\u7b7e
...
@@ -170,8 +170,6 @@ tagsLabel=\u6807\u7b7e
importedLabel
=
\u
5df2
\u
5bfc
\u5165
importedLabel
=
\u
5df2
\u
5bfc
\u5165
captcha1Label=
\u
9a8c
\u
8bc1
\u7801\u
ff1a
captcha1Label=
\u
9a8c
\u
8bc1
\u7801\u
ff1a
captchaLabel
=
\u
9a8c
\u
8bc1
\u7801
captchaLabel
=
\u
9a8c
\u
8bc1
\u7801
clearAllCacheLabel=
\u
6e05
\u9664\u6240\u6709\u9875\u9762\u
7f13
\u
5b58
clearCacheLabel
=
\u
6e05
\u9664\u
672c
\u9875\u
7f13
\u
5b58
indexLabel=
\u9996\u9875
indexLabel=
\u9996\u9875
nextArticle1Label=
\u
65b0
\u
4e00
\u
7bc7
\u
ff1a
nextArticle1Label=
\u
65b0
\u
4e00
\u
7bc7
\u
ff1a
previousArticle1Label
=
\u
65e7
\u
4e00
\u
7bc7
\u
ff1a
previousArticle1Label
=
\u
65e7
\u
4e00
\u
7bc7
\u
ff1a
...
...
war/src/main/webapp/top-bar.ftl
View file @
31a5d8b5
...
@@ -70,14 +70,6 @@
...
@@ -70,14 +70,6 @@
<span class="right" id="admin" data-login="${isLoggedIn?string}">
<span class="right" id="admin" data-login="${isLoggedIn?string}">
<#if isLoggedIn>
<#if isLoggedIn>
<span>${userName}</span>
<span>${userName}</span>
<#if isAdmin>
<a href="javascript:Util.clearCache('all');">
${clearAllCacheLabel}
</a>
<a href="javascript:Util.clearCache();">
${clearCacheLabel}
</a>
</#if>
<#if !isVisitor>
<#if !isVisitor>
<a href="${contextPath}/admin-index.do#main" title="${adminLabel}">
<a href="${contextPath}/admin-index.do#main" title="${adminLabel}">
${adminLabel}
${adminLabel}
...
...
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