Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
a00f0951
Commit
a00f0951
authored
Apr 24, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#216
parent
e70f4bde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
25 deletions
+38
-25
core/src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
...java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
+19
-5
war/src/main/webapp/plugins/b3log-broadcast/plugin.ftl
war/src/main/webapp/plugins/b3log-broadcast/plugin.ftl
+18
-19
war/src/main/webapp/plugins/b3log-broadcast/plugin.properties
...src/main/webapp/plugins/b3log-broadcast/plugin.properties
+1
-1
No files found.
core/src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
View file @
a00f0951
...
...
@@ -18,6 +18,7 @@ package org.b3log.solo.plugin.broadcast;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.concurrent.Future
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -30,6 +31,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessing;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.latke.urlfetch.HTTPRequest
;
import
org.b3log.latke.urlfetch.HTTPResponse
;
import
org.b3log.latke.urlfetch.URLFetchService
;
import
org.b3log.latke.urlfetch.URLFetchServiceFactory
;
import
org.b3log.latke.util.Requests
;
...
...
@@ -49,7 +51,7 @@ import org.json.JSONObject;
* Broadcast chance processor.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.
7, May 16, 2012
* @version 1.0.0.
8, Apr 24, 2013
* @since 0.6.0
*/
@RequestProcessor
...
...
@@ -246,7 +248,7 @@ public final class ChanceProcessor {
* "broadcast": {
* "title": "",
* "content": "",
* "link": ""
* "link": ""
// optional
* }
* }
* </pre>
...
...
@@ -293,16 +295,28 @@ public final class ChanceProcessor {
broadcastRequest
.
put
(
"clientVersion"
,
clientVersion
);
broadcastRequest
.
put
(
"clientName"
,
clientName
);
broadcastRequest
.
put
(
"clientHost"
,
blogHost
);
final
HTTPRequest
httpRequest
=
new
HTTPRequest
();
httpRequest
.
setURL
(
ADD_BROADCAST_URL
);
httpRequest
.
setRequestMethod
(
HTTPRequestMethod
.
POST
);
httpRequest
.
setPayload
(
broadcastRequest
.
toString
().
getBytes
(
"UTF-8"
));
urlFetchService
.
fetchAsync
(
httpRequest
);
@SuppressWarnings
(
"unchecked"
)
final
Future
<
HTTPResponse
>
future
=
(
Future
<
HTTPResponse
>)
urlFetchService
.
fetchAsync
(
httpRequest
);
final
HTTPResponse
result
=
future
.
get
();
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
if
(
HttpServletResponse
.
SC_OK
==
result
.
getResponseCode
())
{
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
optionMgmtService
.
removeOption
(
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
LOGGER
.
info
(
"Submits broadcast successfully"
);
return
;
}
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Submits broadcast failed"
,
e
);
...
...
war/src/main/webapp/plugins/b3log-broadcast/plugin.ftl
View file @
a00f0951
...
...
@@ -33,7 +33,7 @@
plugins.b3logBroadcast = {
init: function() {
$("#loadMsg").text("${loadingLabel}");
// dialog
$("#b3logBroadcastDialog").dialog({
width: 700,
...
...
@@ -96,33 +96,32 @@
url: "http://symphony.b3log.org/apis/broadcasts",
dataType: "jsonp",
jsonp: "callback",
beforeSend: function
() {
beforeSend: function() {
$("#b3logBroadcastList").css("background",
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
},
error: function() {
$("#b3logBroadcastList").html("Loading Symphony broadcasts failed :-(").css("background", "none");
},
success: function(result) {
if (result.sc) {
var articles = result.articles;
if (0 === articles.length) {
return;
}
var articles = result.articles;
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>";
if (0 === articles.length) {
return;
}
$("#b3logBroadcastList").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>";
$("#b3logBroadcastList").html(listHTML).css("background", "none");
},
complete: function(XMLHttpRequest, textStatus) {
$("#loadMsg").text("");
...
...
war/src/main/webapp/plugins/b3log-broadcast/plugin.properties
View file @
a00f0951
...
...
@@ -21,7 +21,7 @@
#
rendererId
=
admin-main.ftl
author
=
<a href="http://88250.b3log.org">88250</a> & <a href="http://vanessa.b3log.org">Vanessa</a>
name
=
b3log b
roadcast
name
=
B3log B
roadcast
version
=
0.0.1
types
=
ADMIN
...
...
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