forked from Archives/Athou_commafeed
bookmarklet for next unread item
This commit is contained in:
@@ -43,7 +43,7 @@ import com.commafeed.frontend.pages.GoogleImportCallbackPage;
|
||||
import com.commafeed.frontend.pages.GoogleImportRedirectPage;
|
||||
import com.commafeed.frontend.pages.HomePage;
|
||||
import com.commafeed.frontend.pages.LogoutPage;
|
||||
import com.commafeed.frontend.pages.TestRssPage;
|
||||
import com.commafeed.frontend.pages.NextUnreadRedirectPage;
|
||||
import com.commafeed.frontend.pages.WelcomePage;
|
||||
import com.commafeed.frontend.utils.exception.DisplayExceptionPage;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
mountPage(GoogleImportCallbackPage.PAGE_PATH,
|
||||
GoogleImportCallbackPage.class);
|
||||
|
||||
mountPage("testfeed", TestRssPage.class);
|
||||
mountPage("next", NextUnreadRedirectPage.class);
|
||||
|
||||
setupInjection();
|
||||
setupSecurity();
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.commafeed.frontend.pages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.request.flow.RedirectToUrlException;
|
||||
import org.apache.wicket.request.mapper.parameter.PageParameters;
|
||||
|
||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.backend.model.UserRole.Role;
|
||||
import com.commafeed.backend.model.UserSettings.ReadingOrder;
|
||||
import com.commafeed.frontend.CommaFeedSession;
|
||||
import com.commafeed.frontend.SecurityCheck;
|
||||
import com.commafeed.frontend.rest.resources.CategoryREST;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@SecurityCheck(Role.USER)
|
||||
public class NextUnreadRedirectPage extends WebPage {
|
||||
|
||||
public static final String PARAM_CATEGORYID = "category";
|
||||
|
||||
@Inject
|
||||
FeedCategoryDAO feedCategoryDAO;
|
||||
|
||||
@Inject
|
||||
FeedEntryStatusDAO feedEntryStatusDAO;
|
||||
|
||||
public NextUnreadRedirectPage(PageParameters params) {
|
||||
String categoryId = params.get(PARAM_CATEGORYID).toString();
|
||||
User user = CommaFeedSession.get().getUser();
|
||||
|
||||
List<FeedEntryStatus> statuses = null;
|
||||
if (StringUtils.isBlank(categoryId)
|
||||
|| CategoryREST.ALL.equals(categoryId)) {
|
||||
statuses = feedEntryStatusDAO.findAll(user, true, 0, 1,
|
||||
ReadingOrder.desc, false);
|
||||
} else {
|
||||
FeedCategory category = feedCategoryDAO.findById(user,
|
||||
Long.valueOf(categoryId));
|
||||
if (category != null) {
|
||||
List<FeedCategory> children = feedCategoryDAO
|
||||
.findAllChildrenCategories(user, category);
|
||||
statuses = feedEntryStatusDAO.findByCategories(children, user,
|
||||
true, 0, 1, ReadingOrder.desc, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(statuses)) {
|
||||
setResponsePage(HomePage.class);
|
||||
} else {
|
||||
FeedEntryStatus status = Iterables.getFirst(statuses, null);
|
||||
String url = status.getEntry().getUrl();
|
||||
status.setRead(true);
|
||||
feedEntryStatusDAO.update(status);
|
||||
throw new RedirectToUrlException(url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ global.cancel=Cancel
|
||||
global.delete=Delete
|
||||
global.required=Required
|
||||
global.download=Download
|
||||
global.link=Link
|
||||
global.bookmark=Bookmark
|
||||
|
||||
tree.subscribe=Subscribe
|
||||
tree.import=Import
|
||||
@@ -87,6 +89,8 @@ about.goodies=Goodies
|
||||
about.goodies.subscribe_url=Subscribe URL
|
||||
about.goodies.chrome_extension=Chrome extension
|
||||
about.goodies.firefox_extension=Firefox extension
|
||||
about.goodies.subscribe_bookmarklet=Add subscription bookmarklet (click)
|
||||
about.goodies.next_unread_bookmarklet=Next unread item bookmarklet (drag to bookmark bar)
|
||||
about.translation=Translation
|
||||
about.translation.message=We need your help to translate CommaFeed.
|
||||
about.translation.link=See how to contribute with translations.
|
||||
|
||||
@@ -936,6 +936,16 @@ function($scope, $location, $state, AdminSettingsService) {
|
||||
};
|
||||
}]);
|
||||
|
||||
module.controller('HelpController', [ '$scope', 'CategoryService',
|
||||
'AnalyticsService',
|
||||
function($scope, CategoryService, AnalyticsService) {
|
||||
|
||||
AnalyticsService.track();
|
||||
$scope.CategoryService = CategoryService;
|
||||
$scope.categoryId = 'all';
|
||||
|
||||
} ]);
|
||||
|
||||
module.controller('FooterController', [ '$scope', function($scope) {
|
||||
|
||||
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
|
||||
@@ -943,4 +953,4 @@ module.controller('FooterController', [ '$scope', function($scope) {
|
||||
$scope.subToMeUrl = baseUrl + 'rest/feed/subscribe?url={feed}';
|
||||
$scope.subToMeName = hostname.indexOf('www.commafeed.com') !== -1 ? 'CommaFeed' : 'CommaFeed (' + hostname + ')';
|
||||
|
||||
} ]);
|
||||
}]);
|
||||
@@ -30,11 +30,6 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
|
||||
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
|
||||
|
||||
var trackCtrl = [ 'AnalyticsService', function(AnalyticsService) {
|
||||
AnalyticsService.track();
|
||||
} ];
|
||||
|
||||
$stateProvider.state('feeds', {
|
||||
'abstract' : true,
|
||||
url : '/feeds',
|
||||
@@ -63,7 +58,7 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
|
||||
$stateProvider.state('feeds.help', {
|
||||
url : '/help',
|
||||
templateUrl : 'templates/feeds.help.html',
|
||||
controller : trackCtrl
|
||||
controller : 'HelpController'
|
||||
});
|
||||
$stateProvider.state('feeds.settings', {
|
||||
url : '/settings',
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
@import "components/admin-panel";
|
||||
@import "components/toolbar";
|
||||
@import "components/entry-list";
|
||||
@import "components/subscription-list";
|
||||
@import "components/subscription-list";
|
||||
@import "components/help";
|
||||
5
src/main/webapp/sass/components/_help.scss
Normal file
5
src/main/webapp/sass/components/_help.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
.help .category-select {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: auto;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="row-fluid">
|
||||
<div class="row-fluid help">
|
||||
<div class="span6">
|
||||
<h4><i class="icon-question-sign"></i> ${toolbar.about}</h4>
|
||||
<p>
|
||||
@@ -21,15 +21,25 @@
|
||||
</form>
|
||||
|
||||
<h4><i class="icon-puzzle-piece"></i> ${about.goodies}</h4>
|
||||
<p>
|
||||
${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://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>
|
||||
<p>
|
||||
${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>
|
||||
${about.goodies.subscribe_bookmarklet}: <a href="https://www.subtome.com/settings.html" target="_blank">SubToMe</a>
|
||||
</p>
|
||||
<p>
|
||||
${about.goodies.next_unread_bookmarklet}: ${subscribe.category}
|
||||
<select ng-model="categoryId" ng-options="cat.id as cat.name for cat in CategoryService.flatCategories"
|
||||
class="category-select">
|
||||
</select>
|
||||
<a href="next?category={{categoryId}}" target="_blank">${global.link}</a>
|
||||
</p>
|
||||
|
||||
<h4><i class="icon-globe"></i> ${about.translation}</h4>
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user