Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
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-1
Commits
7da94004
Unverified
Commit
7da94004
authored
Mar 20, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
#12725
parent
e18a7a02
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
241 additions
and
50 deletions
+241
-50
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+4
-2
src/main/java/org/b3log/solo/processor/console/OtherConsole.java
...n/java/org/b3log/solo/processor/console/OtherConsole.java
+129
-0
src/main/java/org/b3log/solo/processor/console/TagConsole.java
...ain/java/org/b3log/solo/processor/console/TagConsole.java
+0
-44
src/main/java/org/b3log/solo/service/ArchiveDateMgmtService.java
...n/java/org/b3log/solo/service/ArchiveDateMgmtService.java
+86
-0
src/main/resources/lang_en_US.properties
src/main/resources/lang_en_US.properties
+2
-1
src/main/resources/lang_zh_CN.properties
src/main/resources/lang_zh_CN.properties
+2
-1
src/main/webapp/admin/admin-others.ftl
src/main/webapp/admin/admin-others.ftl
+2
-1
src/main/webapp/js/admin/others.js
src/main/webapp/js/admin/others.js
+16
-1
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
7da94004
...
...
@@ -58,7 +58,7 @@ import javax.servlet.http.HttpSessionEvent;
* Solo Servlet listener.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.10.0.1
1, Mar 17
, 2019
* @version 1.10.0.1
2, Mar 20
, 2019
* @since 0.3.1
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
...
@@ -403,7 +403,9 @@ public final class SoloServletListener extends AbstractServletListener {
final
TagConsole
tagConsole
=
beanManager
.
getReference
(
TagConsole
.
class
);
DispatcherServlet
.
get
(
"/console/tags"
,
tagConsole:
:
getTags
);
DispatcherServlet
.
get
(
"/console/tag/unused"
,
tagConsole:
:
getUnusedTags
);
DispatcherServlet
.
delete
(
"/console/tag/unused"
,
tagConsole:
:
removeUnusedTags
);
final
OtherConsole
otherConsole
=
beanManager
.
getReference
(
OtherConsole
.
class
);
DispatcherServlet
.
delete
(
"/console/archive/unused"
,
otherConsole:
:
removeUnusedArchives
);
final
UserConsole
userConsole
=
beanManager
.
getReference
(
UserConsole
.
class
);
DispatcherServlet
.
put
(
"/console/user/"
,
userConsole:
:
updateUser
);
...
...
src/main/java/org/b3log/solo/processor/console/OtherConsole.java
0 → 100644
View file @
7da94004
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
processor
.
console
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.servlet.RequestContext
;
import
org.b3log.latke.servlet.annotation.Before
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JsonRenderer
;
import
org.b3log.solo.service.ArchiveDateMgmtService
;
import
org.b3log.solo.service.TagMgmtService
;
import
org.json.JSONObject
;
/**
* Other console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Mar 20, 2019
* @since 3.4.0
*/
@RequestProcessor
public
class
OtherConsole
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
OtherConsole
.
class
);
/**
* Tag management service.
*/
@Inject
private
TagMgmtService
tagMgmtService
;
/**
* ArchiveDate maangement service.
*/
@Inject
private
ArchiveDateMgmtService
archiveDateMgmtService
;
/**
* Language service.
*/
@Inject
private
LangPropsService
langPropsService
;
/**
* Removes all unused archives.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "msg": ""
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
@Before
(
ConsoleAdminAuthAdvice
.
class
)
public
void
removeUnusedArchives
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
try
{
archiveDateMgmtService
.
removeUnusedArchiveDates
();
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeSuccLabel"
));
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Removes unused archives failed"
,
e
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeFailLabel"
));
}
}
/**
* Removes all unused tags.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "msg": ""
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
@Before
(
ConsoleAdminAuthAdvice
.
class
)
public
void
removeUnusedTags
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
try
{
tagMgmtService
.
removeUnusedTags
();
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeSuccLabel"
));
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Removes unused tags failed"
,
e
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeFailLabel"
));
}
}
}
src/main/java/org/b3log/solo/processor/console/TagConsole.java
View file @
7da94004
...
...
@@ -56,18 +56,6 @@ public class TagConsole {
@Inject
private
TagQueryService
tagQueryService
;
/**
* Tag management service.
*/
@Inject
private
TagMgmtService
tagMgmtService
;
/**
* Language service.
*/
@Inject
private
LangPropsService
langPropsService
;
/**
* Gets all tags.
* <p>
...
...
@@ -148,36 +136,4 @@ public class TagConsole {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
}
}
/**
* Removes all unused tags.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "msg": ""
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
@Before
(
ConsoleAdminAuthAdvice
.
class
)
public
void
removeUnusedTags
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
jsonObject
=
new
JSONObject
();
renderer
.
setJSONObject
(
jsonObject
);
try
{
tagMgmtService
.
removeUnusedTags
();
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeSuccLabel"
));
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Removes unused tags failed"
,
e
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeFailLabel"
));
}
}
}
src/main/java/org/b3log/solo/service/ArchiveDateMgmtService.java
0 → 100644
View file @
7da94004
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
service
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.solo.model.ArchiveDate
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Archive date query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Mar 20, 2019
* @since 3.4.0
*/
@Service
public
class
ArchiveDateMgmtService
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArchiveDateMgmtService
.
class
);
/**
* Archive date repository.
*/
@Inject
private
ArchiveDateRepository
archiveDateRepository
;
/**
* Archive date-Article repository.
*/
@Inject
private
ArchiveDateArticleRepository
archiveDateArticleRepository
;
/**
* Removes all unused archive dates.
*
* @return a list of archive dates, returns an empty list if not found
*/
public
void
removeUnusedArchiveDates
()
{
final
Transaction
transaction
=
archiveDateRepository
.
beginTransaction
();
try
{
final
List
<
JSONObject
>
archiveDates
=
archiveDateRepository
.
getArchiveDates
();
for
(
final
JSONObject
archiveDate
:
archiveDates
)
{
if
(
1
>
archiveDate
.
optInt
(
ArchiveDate
.
ARCHIVE_DATE_T_PUBLISHED_ARTICLE_COUNT
))
{
final
String
archiveDateId
=
archiveDate
.
optString
(
Keys
.
OBJECT_ID
);
archiveDateRepository
.
remove
(
archiveDateId
);
}
}
transaction
.
commit
();
}
catch
(
final
RepositoryException
e
)
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
}
LOGGER
.
log
(
Level
.
ERROR
,
"Gets archive dates failed"
,
e
);
}
}
}
src/main/resources/lang_en_US.properties
View file @
7da94004
...
...
@@ -24,6 +24,7 @@
# Author: Dongxu Wang
#
removeUnusedArchivesLabel
=
Remove Unused Archives
syncGitHubLabel
=
<a href="https://github.com/b3log/solo/issues/12676" target="_blank">Allow sync GitHub repo</a>:
queryUserFailedLabel
=
Query user info failed
commentContentLabel
=
Content
...
...
@@ -33,7 +34,7 @@ pushSuccLabel=Sync Successful
pushToHacpaiLabel
=
Sync to Hacpai
getUploadTokenErrLabel
=
Get community file storage service upload token failed
startToUseLabel
=
Start
clear
TagLabel
=
Clear tag
clear
DataLabel
=
Clear data
exportDataLabel
=
Export data
syncToCommunityLabel
=
Sync to community
cntLabel
=
...
...
src/main/resources/lang_zh_CN.properties
View file @
7da94004
...
...
@@ -24,6 +24,7 @@
# Author: Dongxu Wang
#
removeUnusedArchivesLabel
=
\u
79FB
\u9664\u
672A
\u
4F7F
\u7528\u
5B58
\u6863
syncGitHubLabel
=
<a href="https://github.com/b3log/solo/issues/12676" target="_blank">
\u5141\u
8BB8
\u
540C
\u
6B65 GitHub
\u
4ED3
\u
5E93</a>
\u
FF1A
queryUserFailedLabel
=
\u
67E5
\u
8BE2
\u7528\u6237\u
4FE1
\u
606F
\u5931\u
8D25
commentContentLabel
=
\u
8BC4
\u
8BBA
\u5185\u
5BB9
...
...
@@ -33,7 +34,7 @@ pushSuccLabel=\u63A8\u9001\u6210\u529F
pushToHacpaiLabel
=
\u
63A8
\u9001\u5230\u
793E
\u
533A
getUploadTokenErrLabel
=
\u
83B7
\u
53D6
\u
793E
\u
533A
\u6587\u
4EF6
\u
5B58
\u
50A8
\u
670D
\u
52A1
\u
4E0A
\u
4F20
\u
51ED
\u
8BC1
\u
5F02
\u
5E38
startToUseLabel
=
\u
5F00
\u
59CB
\u
4F7F
\u7528
clear
TagLabel
=
\u6807\u
7B7
E
\u
6E05
\u7406
clear
DataLabel
=
\u6570\u
636
E
\u
6E05
\u7406
exportDataLabel
=
\u6570\u
636E
\u
5BFC
\u
51FA
syncToCommunityLabel
=
\u
540C
\u
6B65
\u5230\u
793E
\u
533A
cntLabel
=
\u
4E2A
...
...
src/main/webapp/admin/admin-others.ftl
View file @
7da94004
...
...
@@ -21,7 +21,7 @@
<ul>
<li>
<div id="tabOthers_tag">
<a href="#tools/others/tag">${clear
Tag
Label}</a>
<a href="#tools/others/tag">${clear
Data
Label}</a>
</div>
</li>
<li>
...
...
@@ -34,6 +34,7 @@
<div id="tabOthersPanel" class="sub-tabs-main">
<div id="tabOthersPanel_tag" class="fn__none">
<button class="fn__margin12" onclick="admin.others.removeUnusedTags();">${removeUnusedTagsLabel}</button>
<button class="fn__margin12" onclick="admin.others.removeUnusedArchives();">${removeUnusedArchivesLabel}</button>
</div>
<div id="tabOthersPanel_data" class="fn__none">
<#if supportExport>
...
...
src/main/webapp/js/admin/others.js
View file @
7da94004
...
...
@@ -20,7 +20,7 @@
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
3.0.0, Nov 11, 2017
* @version 1.
4.0.0, Mar 20, 2019
*/
/* others 相关操作 */
...
...
@@ -32,6 +32,21 @@ admin.others = {
$
(
"
#tabOthers
"
).
tabs
();
$
(
'
#loadMsg
'
).
text
(
''
)
},
/*
* @description 移除未使用的存档
*/
removeUnusedArchives
:
function
()
{
$
(
"
#tipMsg
"
).
text
(
""
);
$
.
ajax
({
url
:
Label
.
servePath
+
"
/console/archive/unused
"
,
type
:
"
DELETE
"
,
cache
:
false
,
success
:
function
(
result
,
textStatus
)
{
$
(
"
#tipMsg
"
).
text
(
result
.
msg
);
}
});
},
/*
* @description 移除未使用的标签
*/
...
...
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