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
1953030e
Unverified
Commit
1953030e
authored
Jan 16, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
#45
parent
6916dad9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
129 deletions
+12
-129
src/main/java/org/b3log/solo/model/Common.java
src/main/java/org/b3log/solo/model/Common.java
+0
-5
src/main/java/org/b3log/solo/repository/CommentRepository.java
...ain/java/org/b3log/solo/repository/CommentRepository.java
+0
-18
src/main/java/org/b3log/solo/service/DataModelService.java
src/main/java/org/b3log/solo/service/DataModelService.java
+0
-51
src/test/java/org/b3log/solo/processor/console/CommentConsoleTestCase.java
.../b3log/solo/processor/console/CommentConsoleTestCase.java
+2
-1
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
.../b3log/solo/repository/ArticleRepositoryImplTestCase.java
+10
-11
src/test/resources/log4j.properties
src/test/resources/log4j.properties
+0
-43
No files found.
src/main/java/org/b3log/solo/model/Common.java
View file @
1953030e
...
...
@@ -102,11 +102,6 @@ public final class Common {
*/
public
static
final
String
RECENT_ARTICLES
=
"recentArticles"
;
/**
* Recent comments.
*/
public
static
final
String
RECENT_COMMENTS
=
"recentComments"
;
/**
* Previous article permalink.
*/
...
...
src/main/java/org/b3log/solo/repository/CommentRepository.java
View file @
1953030e
...
...
@@ -97,24 +97,6 @@ public class CommentRepository extends AbstractRepository {
commentCache
.
putComment
(
comment
);
}
/**
* Gets post comments recently with the specified fetch.
*
* @param fetchSize the specified fetch size
* @return a list of comments recently, returns an empty list if not found
* @throws RepositoryException repository exception
*/
public
List
<
JSONObject
>
getRecentComments
(
final
int
fetchSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setPage
(
1
,
fetchSize
).
setPageCount
(
1
);
final
List
<
JSONObject
>
ret
=
getList
(
query
);
// Removes unpublished article related comments
removeForUnpublishedArticles
(
ret
);
return
ret
;
}
/**
* Gets comments with the specified on id, current page number and
* page size.
...
...
src/main/java/org/b3log/solo/service/DataModelService.java
View file @
1953030e
...
...
@@ -47,8 +47,6 @@ import org.b3log.solo.util.Markdowns;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
import
java.io.StringWriter
;
import
java.util.*
;
...
...
@@ -454,47 +452,6 @@ public class DataModelService {
}
}
/**
* Fills post comments recently.
*
* @param dataModel data model
* @param preference the specified preference
* @throws ServiceException service exception
*/
public
void
fillRecentComments
(
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
preference
)
throws
ServiceException
{
if
(!
preference
.
optBoolean
(
Option
.
ID_C_COMMENTABLE
))
{
dataModel
.
put
(
Common
.
RECENT_COMMENTS
,
Collections
.
emptyList
());
return
;
}
Stopwatchs
.
start
(
"Fill Recent Comments"
);
try
{
LOGGER
.
debug
(
"Filling recent comments...."
);
final
int
recentCommentDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_RECENT_COMMENT_DISPLAY_CNT
);
final
List
<
JSONObject
>
recentComments
=
commentRepository
.
getRecentComments
(
recentCommentDisplayCnt
);
for
(
final
JSONObject
comment
:
recentComments
)
{
String
commentContent
=
comment
.
optString
(
Comment
.
COMMENT_CONTENT
);
commentContent
=
Markdowns
.
toHTML
(
commentContent
);
commentContent
=
Jsoup
.
clean
(
commentContent
,
Whitelist
.
relaxed
());
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
comment
.
put
(
Comment
.
COMMENT_NAME
,
comment
.
getString
(
Comment
.
COMMENT_NAME
));
comment
.
put
(
Comment
.
COMMENT_URL
,
comment
.
getString
(
Comment
.
COMMENT_URL
));
comment
.
put
(
Common
.
IS_REPLY
,
false
);
comment
.
put
(
Comment
.
COMMENT_T_DATE
,
new
Date
(
comment
.
optLong
(
Comment
.
COMMENT_CREATED
)));
comment
.
put
(
"commentDate2"
,
new
Date
(
comment
.
optLong
(
Comment
.
COMMENT_CREATED
)));
}
dataModel
.
put
(
Common
.
RECENT_COMMENTS
,
recentComments
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Fills recent comments failed"
,
e
);
throw
new
ServiceException
(
e
);
}
finally
{
Stopwatchs
.
end
();
}
}
/**
* Fills favicon URL. 可配置 favicon 图标路径 https://github.com/b3log/solo/issues/12706
*
...
...
@@ -742,10 +699,6 @@ public class DataModelService {
if
(
Templates
.
hasExpression
(
template
,
"<#list links as link>"
))
{
fillLinks
(
dataModel
);
}
if
(
Templates
.
hasExpression
(
template
,
"<#list recentComments as comment>"
))
{
fillRecentComments
(
dataModel
,
preference
);
}
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Fills side failed"
,
e
);
throw
new
ServiceException
(
e
);
...
...
@@ -781,10 +734,6 @@ public class DataModelService {
fillCategories
(
dataModel
);
}
if
(
Templates
.
hasExpression
(
template
,
"<#list recentComments as comment>"
))
{
fillRecentComments
(
dataModel
,
preference
);
}
if
(
Templates
.
hasExpression
(
template
,
"<#include \"side.ftl\"/>"
))
{
fillSide
(
context
,
dataModel
,
preference
);
}
...
...
src/test/java/org/b3log/solo/processor/console/CommentConsoleTestCase.java
View file @
1953030e
...
...
@@ -19,6 +19,7 @@ package org.b3log.solo.processor.console;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Query
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.MockRequest
;
import
org.b3log.solo.MockResponse
;
...
...
@@ -95,7 +96,7 @@ public class CommentConsoleTestCase extends AbstractTestCase {
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
removeArticleComment
()
throws
Exception
{
final
List
<
JSONObject
>
recentComments
=
getCommentRepository
().
get
RecentComments
(
1
);
final
List
<
JSONObject
>
recentComments
=
getCommentRepository
().
get
List
(
new
Query
()
);
final
JSONObject
comment
=
recentComments
.
get
(
0
);
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
...
...
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
View file @
1953030e
...
...
@@ -149,7 +149,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
{
"add"
,
"previousAndNext"
,
"getMostCommentArticles"
,
"getMostViewCountArticles"
})
@Test
(
dependsOnMethods
=
{
"add"
,
"previousAndNext"
})
public
void
getRandomly
()
throws
Exception
{
final
ArticleRepository
articleRepository
=
getArticleRepository
();
...
...
@@ -162,19 +162,18 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
{
"add"
,
"previousAndNext"
,
"getMostCommentArticles"
,
"getMostViewCountArticles"
})
@Test
(
dependsOnMethods
=
{
"add"
,
"previousAndNext"
})
public
void
getRecentArticles
()
throws
Exception
{
final
ArticleRepository
articleRepository
=
getArticleRepository
();
Assert
.
assertEquals
(
articleRepository
.
count
(),
4
);
Assert
.
assertEquals
(
articleRepository
.
count
(),
2
);
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
3
);
Assert
.
assertNotNull
(
recentArticles
);
Assert
.
assertEquals
(
recentArticles
.
size
(),
3
);
Assert
.
assertEquals
(
recentArticles
.
size
(),
2
);
Assert
.
assertEquals
(
recentArticles
.
get
(
0
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title3"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
1
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title2"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
2
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title1"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
0
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title2"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
1
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title1"
);
}
/**
...
...
@@ -182,7 +181,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
{
"add"
,
"getMostViewCountArticles"
})
@Test
(
dependsOnMethods
=
{
"add"
})
public
void
isPublished
()
throws
Exception
{
final
ArticleRepository
articleRepository
=
getArticleRepository
();
...
...
@@ -192,9 +191,9 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
final
JSONObject
article
=
all
.
getJSONObject
(
0
);
Assert
.
assertTrue
(
articleRepository
.
isPublished
(
article
.
getString
(
Keys
.
OBJECT_ID
)));
final
JSONObject
notPublished
=
articleRepository
.
getByPermalink
(
"article permalink4
"
);
Assert
.
assertNotNull
(
notP
ublished
);
Assert
.
assertEquals
(
Article
.
ARTICLE_STATUS_C_
DRAFT
,
notP
ublished
.
optInt
(
Article
.
ARTICLE_STATUS
));
final
JSONObject
published
=
articleRepository
.
getByPermalink
(
"article permalink1
"
);
Assert
.
assertNotNull
(
p
ublished
);
Assert
.
assertEquals
(
Article
.
ARTICLE_STATUS_C_
PUBLISHED
,
p
ublished
.
optInt
(
Article
.
ARTICLE_STATUS
));
Assert
.
assertFalse
(
articleRepository
.
isPublished
(
"not found"
));
}
...
...
src/test/resources/log4j.properties
deleted
100644 → 0
View file @
6916dad9
#
# Solo - A small and beautiful blogging system written in Java.
# Copyright (c) 2010-present, b3log.org
#
# 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/>.
#
#
# Description: Solo logging configurations for test.
# Version: 1.0.0.0, Mar 3, 2019
# Author: <a href="http://88250.b3log.org">Liang Ding</a>
#
log4j.rootLogger
=
INFO,stdout
log4j.logger.org.b3log.solo
=
INFO
log4j.logger.org.b3log.latke
=
WARN
log4j.logger.org.b3log.latke.util.freemarker.Templates
=
ERROR
log4j.logger.org.b3log.latke.repository.jdbc.util
=
WARN
log4j.logger.io.netty
=
WARN
log4j.logger.freemarker
=
WARN
log4j.logger.com.zaxxer
=
WARN
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule
=
ERROR
# Console appender
log4j.appender.stdout.Encoding
=
UTF-8
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
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