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
6768e75e
Commit
6768e75e
authored
Dec 17, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12051
parent
5bcb95bd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
287 additions
and
15 deletions
+287
-15
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+45
-6
src/main/java/org/b3log/solo/service/TagQueryService.java
src/main/java/org/b3log/solo/service/TagQueryService.java
+66
-9
src/main/webapp/plugins/symphony-interest/lang_en_US.properties
...in/webapp/plugins/symphony-interest/lang_en_US.properties
+23
-0
src/main/webapp/plugins/symphony-interest/lang_zh_CN.properties
...in/webapp/plugins/symphony-interest/lang_zh_CN.properties
+23
-0
src/main/webapp/plugins/symphony-interest/plugin.ftl
src/main/webapp/plugins/symphony-interest/plugin.ftl
+83
-0
src/main/webapp/plugins/symphony-interest/plugin.properties
src/main/webapp/plugins/symphony-interest/plugin.properties
+31
-0
src/main/webapp/plugins/symphony-interest/style.css
src/main/webapp/plugins/symphony-interest/style.css
+16
-0
No files found.
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
6768e75e
...
...
@@ -15,8 +15,10 @@
*/
package
org
.
b3log
.
solo
.
processor
;
import
java.net.URL
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -40,6 +42,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticQueryService
;
...
...
@@ -48,12 +51,11 @@ import org.b3log.solo.service.UserQueryService;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Blog processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
2.0.4, Nov 20
, 2015
* @version 1.
3.0.4, Dec 17
, 2015
* @since 0.4.6
*/
@RequestProcessor
...
...
@@ -165,7 +167,7 @@ public class BlogProcessor {
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
return
;
}
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
)
{
...
...
@@ -178,7 +180,7 @@ public class BlogProcessor {
httpRequest
.
setRequestMethod
(
HTTPRequestMethod
.
POST
);
final
JSONObject
requestJSONObject
=
new
JSONObject
();
final
JSONObject
admin
=
userQueryService
.
getAdmin
();
final
JSONObject
admin
=
userQueryService
.
getAdmin
();
requestJSONObject
.
put
(
User
.
USER_NAME
,
admin
.
getString
(
User
.
USER_NAME
));
requestJSONObject
.
put
(
User
.
USER_EMAIL
,
admin
.
getString
(
User
.
USER_EMAIL
));
...
...
@@ -211,7 +213,7 @@ public class BlogProcessor {
*/
@RequestProcessing
(
value
=
"/blog/articles-tags"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getArticlesTags
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
throws
Exception
{
final
String
pwd
=
request
.
getParameter
(
"pwd"
);
if
(
Strings
.
isEmptyOrNull
(
pwd
))
{
...
...
@@ -281,4 +283,41 @@ public class BlogProcessor {
}
}
}
/**
* Gets interest tags (top 10 and bottom 10).
*
* <pre>
* {
* "data": ["tag1", "tag2", ....]
* }
* </pre>
*
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
* @throws Exception io exception
*/
@RequestProcessing
(
value
=
"/blog/interest-tags"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getInterestTags
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
final
Set
<
String
>
tagTitles
=
new
HashSet
<
String
>();
final
List
<
JSONObject
>
topTags
=
tagQueryService
.
getTopTags
(
10
);
for
(
final
JSONObject
topTag
:
topTags
)
{
tagTitles
.
add
(
topTag
.
optString
(
Tag
.
TAG_TITLE
));
}
final
List
<
JSONObject
>
bottomTags
=
tagQueryService
.
getBottomTags
(
10
);
for
(
final
JSONObject
bottomTag
:
bottomTags
)
{
tagTitles
.
add
(
bottomTag
.
optString
(
Tag
.
TAG_TITLE
));
}
ret
.
put
(
"data"
,
tagTitles
);
}
}
src/main/java/org/b3log/solo/service/TagQueryService.java
View file @
6768e75e
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
service
;
import
java.util.Iterator
;
import
java.util.List
;
import
javax.inject.Inject
;
...
...
@@ -24,6 +23,7 @@ import org.b3log.latke.logging.Level;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.Query
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.SortDirection
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.util.CollectionUtils
;
...
...
@@ -33,12 +33,11 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Tag query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.3, Jun 28, 2012
* @version 1.
1.0.3, Dec 17, 2015
* @since 0.4.0
*/
@Service
...
...
@@ -59,8 +58,7 @@ public class TagQueryService {
* Gets a tag by the specified tag title.
*
* @param tagTitle the specified tag title
* @return for example,
* <pre>
* @return for example, <pre>
* {
* "tag": {
* "oId": "",
...
...
@@ -70,6 +68,7 @@ public class TagQueryService {
* }
* }
* </pre>, returns {@code null} if not found
*
* @throws ServiceException service exception
*/
public
JSONObject
getTagByTitle
(
final
String
tagTitle
)
throws
ServiceException
{
...
...
@@ -95,7 +94,7 @@ public class TagQueryService {
/**
* Gets the count of tags.
*
*
* @return count of tags
* @throws ServiceException service exception
*/
...
...
@@ -112,13 +111,13 @@ public class TagQueryService {
/**
* Gets all tags.
*
* @return for example,
* <pre>
* @return for example, <pre>
* [
* {"tagTitle": "", "tagReferenceCount": int, ....},
* ....
* ]
* </pre>, returns an empty list if not found
*
* @throws ServiceException service exception
*/
public
List
<
JSONObject
>
getTags
()
throws
ServiceException
{
...
...
@@ -136,6 +135,64 @@ public class TagQueryService {
}
}
/**
* Gets top (reference count descending) tags.
*
* @param fetchSize the specified fetch size
* @return for example, <pre>
* [
* {"tagTitle": "", "tagReferenceCount": int, ....},
* ....
* ]
* </pre>, returns an empty list if not found
*
* @throws ServiceException service exception
*/
public
List
<
JSONObject
>
getTopTags
(
final
int
fetchSize
)
throws
ServiceException
{
try
{
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setPageSize
(
fetchSize
).
addSort
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
,
SortDirection
.
DESCENDING
);
final
JSONObject
result
=
tagRepository
.
get
(
query
);
final
JSONArray
tagArray
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
return
CollectionUtils
.
jsonArrayToList
(
tagArray
);
}
catch
(
final
RepositoryException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Gets top tags failed"
,
e
);
throw
new
ServiceException
(
e
);
}
}
/**
* Gets bottom (reference count ascending) tags.
*
* @param fetchSize the specified fetch size
* @return for example, <pre>
* [
* {"tagTitle": "", "tagReferenceCount": int, ....},
* ....
* ]
* </pre>, returns an empty list if not found
*
* @throws ServiceException service exception
*/
public
List
<
JSONObject
>
getBottomTags
(
final
int
fetchSize
)
throws
ServiceException
{
try
{
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setPageSize
(
fetchSize
).
addSort
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
,
SortDirection
.
ASCENDING
);
final
JSONObject
result
=
tagRepository
.
get
(
query
);
final
JSONArray
tagArray
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
return
CollectionUtils
.
jsonArrayToList
(
tagArray
);
}
catch
(
final
RepositoryException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Gets bottom tags failed"
,
e
);
throw
new
ServiceException
(
e
);
}
}
/**
* Removes tags of unpublished articles from the specified tags.
*
...
...
@@ -157,7 +214,7 @@ public class TagQueryService {
/**
* Sets the tag repository with the specified tag repository.
*
*
* @param tagRepository the specified tag repository
*/
public
void
setTagRepository
(
final
TagRepository
tagRepository
)
{
...
...
src/main/webapp/plugins/symphony-interest/lang_en_US.properties
0 → 100644
View file @
6768e75e
#
# 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 symphony-interest.
# Version: 1.0.0.0, Dec 17, 2015
# Author: Liang Ding
#
interestLabel
=
<a href="http://hacpai.com" target="_blank">Interest</a>
\ No newline at end of file
src/main/webapp/plugins/symphony-interest/lang_zh_CN.properties
0 → 100644
View file @
6768e75e
#
# 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 symphony-interest.
# Version: 1.0.0.0, Dec 17, 2015
# Author: Liang Ding
#
interestLabel
=
<a href="http://hacpai.com" target="_blank">
\u
793e
\u
533a
\u
63a8
\u8350
</a>
src/main/webapp/plugins/symphony-interest/plugin.ftl
0 → 100644
View file @
6768e75e
<link type="text/css" rel="stylesheet" href="${staticServePath}/plugins/symphony-interest/style.css"/>
<div id="symphonyInterestPanel">
<div class="module-panel">
<div class="module-header">
<h2>${interestLabel}</h2>
</div>
<div class="module-body padding12">
<div id="symphonyInterest">
</div>
</div>
</div>
</div>
<script type="text/javascript">
plugins.symphonyInterest = {
init: function () {
$("#loadMsg").text("${loadingLabel}");
$("#symphonyInterest").css("background",
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
$.ajax({
url: "${servePath}/blog/interest-tags",
type: "GET",
dataType: "json",
error: function () {
$("#symphonyInterest").html("Loading Interest failed :-(").css("background", "none");
},
success: function (result, textStatus) {
var tags = result.data;
if (0 === tags.length) {
return;
}
$.ajax({
url: "http://hacpai.com/apis/articles?p=1&size=7&tags=" + tags.join(),
type: "GET",
dataType: "jsonp",
jsonp: "callback",
error: function () {
$("#symphonyInterest").html("Loading Interest failed :-(").css("background", "none");
},
success: function (data, textStatus) {
var articles = data.articles;
if (0 === articles.length) {
return;
}
var listHTML = "<ul>";
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var articleLiHtml = "<li>"
+ "<a target='_blank' href='" + article.articlePermalink + "'>"
+ article.articleTitle + "</a> <span class='date'>" + $.bowknot.getDate(article.articleCreateTime, 1);
+"</span></li>"
listHTML += articleLiHtml
}
listHTML += "</ul>";
$("#symphonyInterest").html(listHTML).css("background", "none");
}
});
}
});
$("#loadMsg").text("");
}
};
/*
* 添加插件
*/
admin.plugin.add({
"id": "symphonyInterest",
"path": "/main/panel1",
"content": $("#symphonyInterestPanel").html()
});
// 移除现有内容
$("#symphonyInterestPanel").remove();
</script>
src/main/webapp/plugins/symphony-interest/plugin.properties
0 → 100644
View file @
6768e75e
#
# 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 symphony-interest.
# Version: 1.0.0.0, Dec 17, 2015
# Author: Liang Ding
#
rendererId
=
admin-main.ftl
author
=
<a href="http://88250.b3log.org">88250</a>
name
=
Symphony Interest
version
=
0.0.1
types
=
ADMIN
classesDirPath
=
/WEB-INF/classes/
pluginClass
=
eventListenerClasses
=
\ No newline at end of file
src/main/webapp/plugins/symphony-interest/style.css
0 → 100644
View file @
6768e75e
/*
* plugin style for symphony-interest
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.1, Aug 9, 2011
*/
#symphonyInterest
ul
{
list-style
:
none
;
}
#symphonyInterest
a
{
text-decoration
:
none
;
}
#symphonyInterest
.date
{
color
:
#686868
;
font-size
:
12px
;
}
\ No newline at end of file
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