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
df8b2e62
Unverified
Commit
df8b2e62
authored
Oct 20, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
删除获取 top 标签接口
parent
35a03bd1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
118 deletions
+34
-118
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+1
-41
src/test/java/org/b3log/solo/processor/BlogProcessorTestCase.java
.../java/org/b3log/solo/processor/BlogProcessorTestCase.java
+1
-28
src/test/resources/plugins/symphony-interest/plugin.ftl
src/test/resources/plugins/symphony-interest/plugin.ftl
+32
-49
No files found.
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
df8b2e62
...
@@ -34,7 +34,6 @@ import org.b3log.latke.util.Strings;
...
@@ -34,7 +34,6 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -42,15 +41,12 @@ import org.json.JSONObject;
...
@@ -42,15 +41,12 @@ import org.json.JSONObject;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* Blog processor.
* Blog processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.
4, Sep 16
, 2018
* @version 1.3.1.
5, Oct 20
, 2018
* @since 0.4.6
* @since 0.4.6
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -255,40 +251,4 @@ public class BlogProcessor {
...
@@ -255,40 +251,4 @@ public class BlogProcessor {
}
}
}
}
}
}
/**
* Gets interest tags (top 10 and bottom 10).
* <p>
* <pre>
* {
* "data": ["tag1", "tag2", ....]
* }
* </pre>
* </p>
*
* @param context the specified context
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/blog/interest-tags"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getInterestTags
(
final
HTTPRequestContext
context
)
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
final
Set
<
String
>
tagTitles
=
new
HashSet
<>();
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/test/java/org/b3log/solo/processor/BlogProcessorTestCase.java
View file @
df8b2e62
...
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.when;
...
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.when;
* {@link BlogProcessor} test case.
* {@link BlogProcessor} test case.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
0, Nov 1, 2016
* @version 1.0.0.
1, Oct 20, 2018
* @since 1.7.0
* @since 1.7.0
*/
*/
@Test
(
suiteName
=
"processor"
)
@Test
(
suiteName
=
"processor"
)
...
@@ -119,31 +119,4 @@ public class BlogProcessorTestCase extends AbstractTestCase {
...
@@ -119,31 +119,4 @@ public class BlogProcessorTestCase extends AbstractTestCase {
final
String
content
=
stringWriter
.
toString
();
final
String
content
=
stringWriter
.
toString
();
Assert
.
assertTrue
(
StringUtils
.
startsWith
(
content
,
"{\"data\":"
));
Assert
.
assertTrue
(
StringUtils
.
startsWith
(
content
,
"{\"data\":"
));
}
}
/**
* getInterestTags.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
getInterestTags
()
throws
Exception
{
final
HttpServletRequest
request
=
mock
(
HttpServletRequest
.
class
);
when
(
request
.
getServletContext
()).
thenReturn
(
mock
(
ServletContext
.
class
));
when
(
request
.
getRequestURI
()).
thenReturn
(
"/blog/interest-tags"
);
when
(
request
.
getMethod
()).
thenReturn
(
"GET"
);
final
MockDispatcherServlet
dispatcherServlet
=
new
MockDispatcherServlet
();
dispatcherServlet
.
init
();
final
StringWriter
stringWriter
=
new
StringWriter
();
final
PrintWriter
printWriter
=
new
PrintWriter
(
stringWriter
);
final
HttpServletResponse
response
=
mock
(
HttpServletResponse
.
class
);
when
(
response
.
getWriter
()).
thenReturn
(
printWriter
);
dispatcherServlet
.
service
(
request
,
response
);
final
String
content
=
stringWriter
.
toString
();
Assert
.
assertTrue
(
StringUtils
.
startsWith
(
content
,
"{\"data\":"
));
}
}
}
src/test/resources/plugins/symphony-interest/plugin.ftl
View file @
df8b2e62
...
@@ -32,71 +32,54 @@
...
@@ -32,71 +32,54 @@
<script type="text/javascript">
<script type="text/javascript">
plugins.symphonyInterest = {
plugins.symphonyInterest = {
init: function () {
init: function () {
$(
"#loadMsg").text("${loadingLabel}");
$(
'#loadMsg').text("${loadingLabel}")
$(
"#symphonyInterest").css("background"
,
$(
'#symphonyInterest').css('background'
,
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent")
;
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent")
$.ajax({
$.ajax({
url: "${servePath}/blog/interest-tags",
url: 'https://hacpai.com/apis/articles?',
type: "GET",
type: 'GET',
dataType: "json",
dataType: 'jsonp',
jsonp: 'callback',
error: function () {
error: function () {
$(
"#symphonyInterest").html("Loading Interest failed :-(").css("background", "none");
$(
'#symphonyInterest').html('Loading Interest failed :-(').css('background', 'none')
},
},
success: function (
result
, textStatus) {
success: function (
data
, textStatus) {
var
tags = result.data;
var
articles = data.articles
if (0 ===
tag
s.length) {
if (0 ===
article
s.length) {
return
;
return
}
}
$.ajax({
url: "https://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");
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("");
$(
'#loadMsg').text('')
}
}
}
;
}
/*
/*
* 添加插件
* 添加插件
*/
*/
admin.plugin.add({
admin.plugin.add({
"id": "symphonyInterest"
,
'id': 'symphonyInterest'
,
"path": "/main/panel1"
,
'path': '/main/panel1'
,
"content": $("#symphonyInterestPanel"
).html()
'content': $('#symphonyInterestPanel'
).html()
})
;
})
// 移除现有内容
// 移除现有内容
$(
"#symphonyInterestPanel").remove();
$(
'#symphonyInterestPanel').remove()
</script>
</script>
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