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
58fa56fb
Commit
58fa56fb
authored
Aug 03, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12026
parent
5dcf074a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
29 deletions
+55
-29
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
.../main/java/org/b3log/solo/processor/ArticleProcessor.java
+10
-10
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
.../src/main/java/org/b3log/solo/processor/TagProcessor.java
+8
-10
core/src/main/java/org/b3log/solo/processor/util/Filler.java
core/src/main/java/org/b3log/solo/processor/util/Filler.java
+37
-9
No files found.
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
58fa56fb
...
...
@@ -412,12 +412,12 @@ public class ArticleProcessor {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
...
...
@@ -480,12 +480,12 @@ public class ArticleProcessor {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
...
...
@@ -551,12 +551,12 @@ public class ArticleProcessor {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
...
...
@@ -620,7 +620,7 @@ public class ArticleProcessor {
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByAuthorEmail
(
authorEmail
,
currentPageNum
,
pageSize
);
if
(!
articles
.
isEmpty
())
{
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
final
int
articleCount
=
author
.
getInt
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
);
...
...
@@ -718,7 +718,7 @@ public class ArticleProcessor {
}
}
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
if
(
preference
.
optBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_UPDATE_DATE_COMPARATOR
);
...
...
@@ -814,12 +814,12 @@ public class ArticleProcessor {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
...
...
core/src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
58fa56fb
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
processor
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
...
...
@@ -56,7 +55,6 @@ import org.b3log.solo.util.comparator.Comparators;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Tag processor.
*
...
...
@@ -147,7 +145,7 @@ public class TagProcessor {
return
;
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Tag[title={0}, currentPageNum={1}]"
,
new
Object
[]
{
tagTitle
,
currentPageNum
});
LOGGER
.
log
(
Level
.
DEBUG
,
"Tag[title={0}, currentPageNum={1}]"
,
new
Object
[]{
tagTitle
,
currentPageNum
});
tagTitle
=
URLDecoder
.
decode
(
tagTitle
,
"UTF-8"
);
final
JSONObject
result
=
tagQueryService
.
getTagByTitle
(
tagTitle
);
...
...
@@ -181,19 +179,19 @@ public class TagProcessor {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
articles
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
// All articles composed by the same author
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
articles
,
author
,
preference
);
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
final
int
tagArticleCount
=
tag
.
getInt
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
);
final
int
pageCount
=
(
int
)
Math
.
ceil
((
double
)
tagArticleCount
/
(
double
)
pageSize
);
LOGGER
.
log
(
Level
.
TRACE
,
"Paginate tag-articles[currentPageNum={0}, pageSize={1}, pageCount={2}, windowSize={3}]"
,
new
Object
[]
{
currentPageNum
,
pageSize
,
pageCount
,
windowSize
});
new
Object
[]
{
currentPageNum
,
pageSize
,
pageCount
,
windowSize
});
final
List
<
Integer
>
pageNums
=
Paginator
.
paginate
(
currentPageNum
,
pageSize
,
pageCount
,
windowSize
);
LOGGER
.
log
(
Level
.
TRACE
,
"tag-articles[pageNums={0}]"
,
pageNums
);
...
...
@@ -208,7 +206,7 @@ public class TagProcessor {
filler
.
fillSide
(
request
,
dataModel
,
preference
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
@@ -239,9 +237,9 @@ public class TagProcessor {
* @param pageNums the specified page numbers
*/
private
void
fillPagination
(
final
Map
<
String
,
Object
>
dataModel
,
final
int
pageCount
,
final
int
currentPageNum
,
final
List
<
JSONObject
>
articles
,
final
List
<
Integer
>
pageNums
)
{
final
int
pageCount
,
final
int
currentPageNum
,
final
List
<
JSONObject
>
articles
,
final
List
<
Integer
>
pageNums
)
{
final
String
previousPageNum
=
Integer
.
toString
(
currentPageNum
>
1
?
currentPageNum
-
1
:
0
);
dataModel
.
put
(
Pagination
.
PAGINATION_PREVIOUS_PAGE_NUM
,
"0"
.
equals
(
previousPageNum
)
?
""
:
previousPageNum
);
...
...
core/src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
58fa56fb
...
...
@@ -39,6 +39,7 @@ import org.b3log.latke.model.Plugin;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.plugin.ViewLoadEventData
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.user.UserService
;
...
...
@@ -47,6 +48,7 @@ import org.b3log.latke.util.*;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.*
;
import
static
org
.
b3log
.
solo
.
model
.
Article
.
ARTICLE_CONTENT
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.CommentRepository
;
...
...
@@ -68,7 +70,7 @@ import org.json.JSONObject;
* Filler utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1
0.11, Jul 2
, 2015
* @version 1.3.1
1.11, Aug 3
, 2015
* @since 0.3.1
*/
@Service
...
...
@@ -173,6 +175,12 @@ public class Filler {
@Inject
private
EventManager
eventManager
;
/**
* Language service.
*/
@Inject
private
LangPropsService
langPropsService
;
/**
* Fills articles in index.ftl.
*
...
...
@@ -238,12 +246,12 @@ public class Filler {
final
boolean
hasMultipleUsers
=
userQueryService
.
hasMultipleUsers
();
if
(
hasMultipleUsers
)
{
setArticlesExProperties
(
articles
,
preference
);
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
setArticlesExProperties
(
articles
,
author
,
preference
);
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
...
...
@@ -883,13 +891,15 @@ public class Filler {
* }
* </pre> </p>
*
* @param request the specified HTTP servlet request
* @param article the specified article
* @param author the specified author
* @param preference the specified preference
* @throws ServiceException service exception
* @see #setArticlesExProperties(java.util.List, org.json.JSONObject)
*/
private
void
setArticleExProperties
(
final
JSONObject
article
,
final
JSONObject
author
,
final
JSONObject
preference
)
private
void
setArticleExProperties
(
final
HttpServletRequest
request
,
final
JSONObject
article
,
final
JSONObject
author
,
final
JSONObject
preference
)
throws
ServiceException
{
try
{
final
String
authorName
=
author
.
getString
(
User
.
USER_NAME
);
...
...
@@ -908,6 +918,12 @@ public class Filler {
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
}
if
(
articleQueryService
.
needViewPwd
(
request
,
article
))
{
final
String
content
=
langPropsService
.
get
(
"articleContentPwd"
);
article
.
put
(
ARTICLE_CONTENT
,
content
);
}
processArticleAbstract
(
preference
,
article
);
articleQueryService
.
markdown
(
article
);
...
...
@@ -933,12 +949,14 @@ public class Filler {
* }
* </pre> </p>
*
* @param request the specified HTTP servlet request
* @param article the specified article
* @param preference the specified preference
* @throws ServiceException service exception
* @see #setArticlesExProperties(java.util.List, org.json.JSONObject)
*/
private
void
setArticleExProperties
(
final
JSONObject
article
,
final
JSONObject
preference
)
throws
ServiceException
{
private
void
setArticleExProperties
(
final
HttpServletRequest
request
,
final
JSONObject
article
,
final
JSONObject
preference
)
throws
ServiceException
{
try
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
article
);
final
String
authorName
=
author
.
getString
(
User
.
USER_NAME
);
...
...
@@ -957,6 +975,12 @@ public class Filler {
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
}
if
(
articleQueryService
.
needViewPwd
(
request
,
article
))
{
final
String
content
=
langPropsService
.
get
(
"articleContentPwd"
);
article
.
put
(
ARTICLE_CONTENT
,
content
);
}
processArticleAbstract
(
preference
,
article
);
articleQueryService
.
markdown
(
article
);
...
...
@@ -984,16 +1008,18 @@ public class Filler {
* }
* </pre> </p>
*
* @param request the specified HTTP servlet request
* @param articles the specified articles
* @param author the specified author
* @param preference the specified preference
* @throws ServiceException service exception
* @see #setArticleExProperties(org.json.JSONObject, org.json.JSONObject)
*/
public
void
setArticlesExProperties
(
final
List
<
JSONObject
>
articles
,
final
JSONObject
author
,
final
JSONObject
preference
)
public
void
setArticlesExProperties
(
final
HttpServletRequest
request
,
final
List
<
JSONObject
>
articles
,
final
JSONObject
author
,
final
JSONObject
preference
)
throws
ServiceException
{
for
(
final
JSONObject
article
:
articles
)
{
setArticleExProperties
(
article
,
author
,
preference
);
setArticleExProperties
(
request
,
article
,
author
,
preference
);
}
}
...
...
@@ -1015,15 +1041,17 @@ public class Filler {
* }
* </pre> </p>
*
* @param request the specified HTTP servlet request
* @param articles the specified articles
* @param preference the specified preference
* @throws ServiceException service exception
* @see #setArticleExProperties(org.json.JSONObject, org.json.JSONObject)
*/
public
void
setArticlesExProperties
(
final
List
<
JSONObject
>
articles
,
final
JSONObject
preference
)
public
void
setArticlesExProperties
(
final
HttpServletRequest
request
,
final
List
<
JSONObject
>
articles
,
final
JSONObject
preference
)
throws
ServiceException
{
for
(
final
JSONObject
article
:
articles
)
{
setArticleExProperties
(
article
,
preference
);
setArticleExProperties
(
request
,
article
,
preference
);
}
}
...
...
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