mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
subscribe by url callback and subtome support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.commafeed.frontend.rest.resources;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -229,6 +230,29 @@ public class FeedREST extends AbstractResourceREST {
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/subscribe")
|
||||
@ApiOperation(value = "Subscribe to a feed", notes = "Subscribe to a feed")
|
||||
public Response subscribe(
|
||||
@ApiParam(value = "feed url", required = true) @QueryParam("url") String url) {
|
||||
|
||||
try {
|
||||
Preconditions.checkNotNull(url);
|
||||
|
||||
url = prependHttp(url);
|
||||
url = ((FeedInfo) fetchFeed(url).getEntity()).getUrl();
|
||||
|
||||
FeedInfo info = (FeedInfo) fetchFeed(url).getEntity();
|
||||
feedSubscriptionService.subscribe(getUser(), info.getUrl(),
|
||||
info.getTitle(), null);
|
||||
} catch (Exception e) {
|
||||
log.info("Could not subscribe to url {} : {}", url, e.getMessage());
|
||||
}
|
||||
return Response.temporaryRedirect(
|
||||
URI.create(applicationSettingsService.get().getPublicUrl()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private String prependHttp(String url) {
|
||||
if (!url.startsWith("http")) {
|
||||
url = "http://" + url;
|
||||
|
||||
@@ -84,6 +84,9 @@ about.line2_prefix=If you encounter an issue, please report it on the issues pag
|
||||
about.line2_suffix= project.
|
||||
about.line3=If you like this project, please consider a donation to support the developer and help cover the costs of keeping this website online.
|
||||
about.goodies=Goodies
|
||||
about.goodies.subscribe_url=Subscribe URL
|
||||
about.goodies.chrome_extension=Chrome extension
|
||||
about.goodies.firefox_extension=Firefox extension
|
||||
about.translation=Translation
|
||||
about.translation.message=We need your help to translate CommaFeed.
|
||||
about.translation.link=See how to contribute with translations.
|
||||
|
||||
@@ -934,4 +934,15 @@ function($scope, $location, $state, AdminSettingsService) {
|
||||
$scope.toUsers = function() {
|
||||
$state.transitionTo('admin.userlist');
|
||||
};
|
||||
}]);
|
||||
}]);
|
||||
|
||||
module.controller('FooterController', [ '$scope', '$location', '$state',
|
||||
'AdminSettingsService',
|
||||
function($scope, $location, $state, AdminSettingsService) {
|
||||
|
||||
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
|
||||
var hostname = window.location.hostname;
|
||||
$scope.subToMeUrl = baseUrl + 'rest/feed/subscribe?url={feed}';
|
||||
$scope.subToMeName = hostname.indexOf('www.commafeed.com') !== -1 ? 'CommaFeed' : 'CommaFeed (' + hostname + ')';
|
||||
|
||||
} ]);
|
||||
3
src/main/webapp/templates/_footer.html
Normal file
3
src/main/webapp/templates/_footer.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div ng-controller="FooterController">
|
||||
<iframe ui-if="subToMeUrl" style="display:none;" src='https://www.subtome.com/register.html?name={{subToMeName}}&url={{subToMeUrl}}'></iframe>
|
||||
</div>
|
||||
@@ -22,10 +22,13 @@
|
||||
|
||||
<h3>${about.goodies}</h3>
|
||||
<p>
|
||||
<a href="https://chrome.google.com/webstore/detail/commafeed/bpbfpjiciblcfeganojjkfapnllbhdga" target="_blank">Chrome extension</a>
|
||||
${about.goodies.subscribe_url}: <a href="rest/feed/subscribe?url=FEED_URL_HERE" target="_blank">rest/feed/subscribe?url=FEED_URL_HERE</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://addons.mozilla.org/en-US/firefox/addon/commafeed/" target="_blank">Firefox extension</a>
|
||||
<a href="https://chrome.google.com/webstore/detail/commafeed/bpbfpjiciblcfeganojjkfapnllbhdga" target="_blank">${about.goodies.chrome_extension}</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://addons.mozilla.org/en-US/firefox/addon/commafeed/" target="_blank">${about.goodies.firefox_extension}</a>
|
||||
</p>
|
||||
|
||||
<h3>${about.translation}</h3>
|
||||
|
||||
@@ -13,4 +13,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-include="'templates/_footer.html'"></div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user