Compare commits

..

97 Commits
2.0.3 ... 2.1.0

Author SHA1 Message Date
Athou
68f9852790 2.1.0 release 2014-12-12 08:27:49 +01:00
Athou
d0150de003 discourage h2 usage (fix #689) 2014-12-11 15:55:40 +01:00
Athou
e2b792335b split orphan cleanup task in two 2014-12-11 08:46:09 +01:00
Athou
ece38c9e59 only add enclosure if there's one 2014-12-11 08:32:48 +01:00
Athou
a19b5090bf expose enclosures in generated feeds (fix #690) 2014-12-10 18:54:35 +01:00
Athou
e4b3c35892 extract version as a variable 2014-12-09 15:30:48 +01:00
Athou
4b229a759a frontend plugin update 2014-12-09 10:57:52 +01:00
Athou
1e9e42ac48 liquibase upgrade for faster app startup, remove when 3.3.1 is included in dropwizard 2014-12-09 10:35:24 +01:00
Athou
245a48f66e guice update 2014-12-09 10:27:56 +01:00
Athou
e6d8397550 optimize opml export (fix #687) 2014-12-08 08:07:20 +01:00
Athou
d59bd43846 querydsl update 2014-12-06 17:21:14 +01:00
Athou
c1579c83c7 junit update 2014-12-06 17:21:06 +01:00
Athou
4d782e60ad readme update 2014-12-05 08:22:00 +01:00
Athou
c702f47927 more config checks on startup 2014-12-04 14:04:03 +01:00
Athou
9110cfd923 new setting for deleting old entries (fix #524) 2014-12-04 10:27:07 +01:00
Athou
e40dd14bbf reduce default sql logging level for dev 2014-12-04 09:12:08 +01:00
Athou
90aaae9959 Merge pull request #686 from ebraminio/master
Support Android 5.0 bits
2014-12-03 18:15:28 +01:00
Ebrahim Byagowi
e81dda0fa8 Support Android 5.0 bits
http://updates.html5rocks.com/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
2014-12-03 16:57:35 +00:00
Athou
f93796d036 fix for "handshake alert: unrecognized_name" (fix #685) 2014-12-01 16:19:30 +01:00
Athou
d06359cb81 remove deb package creation (fix #684) 2014-12-01 16:02:41 +01:00
Athou
8b68fb578f swagger upgrade (no longer includes logback.xml) 2014-11-27 22:04:13 +01:00
Athou
cca300e419 simpler support for single quotes (#681) 2014-11-26 15:25:38 +01:00
Athou
77c3ec0bbe support for single quotes (#681) 2014-11-26 14:19:08 +01:00
Athou
ed81fc576a fix tagging issues 2014-11-25 10:30:14 +01:00
Athou
435fcb9669 unused method 2014-11-24 16:27:32 +01:00
Athou
9020d95b62 better character encoding detection 2014-11-24 14:55:20 +01:00
Athou
84d7a501d4 directory name change since it's devicejs on bower 2014-11-24 14:17:38 +01:00
Athou
e65dd49d69 use released version of device.js 2014-11-24 13:13:43 +01:00
Athou
a705cbe6c2 instantiate filtering service only once 2014-11-24 12:56:55 +01:00
Athou
60b8af3860 typos 2014-11-24 12:53:13 +01:00
Athou
9ac4187aa8 let the module decide what tasks are registered 2014-11-24 12:49:54 +01:00
Athou
6419d29489 demo account creation is now skipped by default 2014-11-23 13:27:34 +01:00
Athou
4684e43f42 relax opml import conditions (#677) 2014-11-22 22:29:56 +01:00
Athou
a477c9fa6d fix error display 2014-11-22 11:53:53 +01:00
Athou
d1be331f99 handle nulls correctly 2014-11-22 11:53:46 +01:00
Athou
cbc792d406 use the old id generator as it's the one we were using before dropwizard 2014-11-21 16:50:20 +01:00
Athou
0313c5c560 fix placeholder display 2014-11-21 12:04:59 +01:00
Athou
18aa2fcd92 fix subscription error handling 2014-11-21 10:06:48 +01:00
Athou
10461941d7 fix nightsky loadingbar color 2014-11-21 10:01:34 +01:00
Athou
e6050219bc log runtime exceptions 2014-11-20 14:50:24 +01:00
Athou
81481c37fe use daemon threads 2014-11-20 12:26:48 +01:00
Athou
5ea92a7d18 jedis upgrade 2014-11-18 17:27:06 +01:00
Athou
f40630aced upgrade dev dependencies 2014-11-18 12:43:23 +01:00
Athou
81850acdfe enable livereload 2014-11-18 12:24:36 +01:00
Athou
6819d5aa8b highlight unread categories 2014-11-18 12:13:13 +01:00
Athou
2aef4e5d05 typo 2014-11-17 16:06:31 +01:00
Athou
6d4d2c3e7e lang() is deprecated 2014-11-17 16:05:19 +01:00
Athou
87bcaa4731 nightsky theme tweaks 2014-11-17 15:37:19 +01:00
Athou
5d2378f291 swagger ui upgrade 2014-11-17 14:44:05 +01:00
Athou
253507d14b momentjs upgrade 2014-11-17 14:37:48 +01:00
Athou
548fb7099b ui router upgrade 2014-11-17 14:28:24 +01:00
Athou
0dd7c777ee bootstrap upgrade 2014-11-17 14:24:32 +01:00
Athou
6812bf2388 jquery upgrade 2014-11-17 14:24:27 +01:00
Athou
12bcbfa9f7 angular upgrade 2014-11-17 14:24:16 +01:00
Athou
b5dfd371d9 typo 2014-11-17 06:44:11 +01:00
Athou
e09d7fb103 new dark theme 'nightsky' 2014-11-14 16:10:06 +01:00
Athou
0fe3afe254 remove underline on focused link 2014-11-12 09:05:25 +01:00
Athou
db50d50c19 remove dotted lines on focused links 2014-11-11 20:45:55 +01:00
Athou
691bdb1512 force g++ install (fix #673) 2014-11-11 08:55:29 +01:00
Athou
d50b712bca commons-codec upgrade 2014-11-10 10:23:01 +01:00
Athou
3b68e4f32b changelog update 2014-11-10 10:18:20 +01:00
Athou
259b9a90dd clarify help text 2014-11-10 10:16:15 +01:00
Athou
f4c5fd7eb4 wrap class cast exceptions 2014-11-10 10:14:19 +01:00
Athou
3cd42d03f0 reduce horizontal form height 2014-11-10 10:10:41 +01:00
Athou
3497b82e8c liquibase upgrade seems to change checksum here 2014-11-10 10:10:25 +01:00
Athou
15a24e4e75 fix components layout 2014-11-10 10:04:29 +01:00
Athou
96837f908e refactor into a service 2014-11-10 09:49:59 +01:00
Athou
4ea5ebbf9e Merge branch 'entry-filtering' 2014-11-10 09:20:26 +01:00
Athou
281e015376 help block added 2014-11-10 09:12:10 +01:00
Athou
5825a16aff changelog update 2014-11-09 21:25:03 +01:00
Athou
2586a8c433 dropwizard upgrade 2014-11-09 21:13:39 +01:00
Athou
9f7c9c3428 unused code cleanup 2014-11-07 15:02:38 +01:00
Athou
9790ba735b facebook favicon fetcher 2014-11-07 15:02:11 +01:00
Athou
e3dbcac9fb dependencies upgrade 2014-11-07 10:59:04 +01:00
Athou
1c99929429 exclude terms from search (fix #666) 2014-11-07 10:53:49 +01:00
Athou
9b2cdbbb18 fix readability icon position on safari (fix #651) 2014-11-07 10:26:58 +01:00
Athou
928cf1220e config placeholder 2014-11-07 09:41:01 +01:00
Athou
c0557856a3 configurable "from" address (fix #664) 2014-11-07 09:38:55 +01:00
Athou
97c2cc3d15 unit tests for opml importer (#636) 2014-11-07 09:00:53 +01:00
Athou
a94ef980bb cannot loop forever 2014-11-07 08:46:09 +01:00
Athou
eea0c24d2b engine is now strict and throws exceptions instead of returning nulls 2014-11-04 16:25:34 +01:00
Athou
c8fded3c56 don't crash if we cannot evaluate the filter 2014-11-04 16:19:50 +01:00
Athou
8f2ba5e186 initial ui for entry filtering 2014-11-04 16:01:37 +01:00
Athou
5ce2823d0b strip html tags 2014-11-04 15:22:43 +01:00
Athou
a0c70d326f class not used anymore 2014-11-04 15:09:45 +01:00
Athou
5f28fd4114 initial support for entry filtering 2014-11-04 15:07:12 +01:00
Athou
7151db0909 Merge pull request #662 from Athou/dw8
dropwizard upgrade
2014-11-01 11:20:44 +01:00
Athou
e82888f8f3 Merge pull request #661 from Hubcapp/master
Mark Read button now respects filters
2014-11-01 11:18:50 +01:00
Tyler Gebhard
4fb60a6ec6 The "Mark Read" button now only marks the visible entries as read, instead of the entire feed regardless of what keywords you've entered. This should allow better management of RSS feeds, if you don't want to ever look at any content which has certain keywords in it. 2014-11-01 02:10:31 -04:00
Hubcapp
27f22f6094 Merge pull request #3 from Athou/master
back up to date
2014-11-01 02:01:24 -04:00
Athou
7497a0151a upgrade instructions 2014-10-29 08:46:24 +01:00
Athou
41f133afb1 liquibade upgrade fix 2014-10-29 08:46:24 +01:00
Athou
4b15ecbc1b more comments 2014-10-29 08:46:23 +01:00
Athou
6498130850 remove app.contextPath setting 2014-10-29 08:46:23 +01:00
Athou
24bd1121af commons-lang upgrade to v3 2014-10-29 08:46:23 +01:00
Athou
3cccf741d6 dropwizard upgrade to 0.8.0 2014-10-29 08:46:10 +01:00
Athou
0a2d2c3f43 fix travis build 2014-10-29 08:42:32 +01:00
99 changed files with 1593 additions and 527 deletions

View File

@@ -1,15 +1,15 @@
# CommaFeed settings
# ------------------
app:
# context path of the application
contextPath: /
# url used to access commafeed
publicUrl: https://@OPENSHIFT_APP_DNS@/
# wether to allow user registrations
allowRegistrations: false
# create a demo account the first time the app starts
createDemoAccount: false
# put your google analytics tracking code here
googleAnalyticsTrackingCode:
@@ -47,6 +47,9 @@ app:
# time to keep unread statuses (in days), 0 to disable
keepStatusDays: 0
# entries to keep per feed, old entries will be deleted, 0 to disable
maxFeedCapacity: 500
# cache service to use, possible values are 'noop' and 'redis'
cache: noop

View File

@@ -1,3 +1,11 @@
v 2.1.0
- dropwizard upgrade to 0.8.0
- you have to remove the "app.contextPath" setting from your yml file, you can optionally use server.applicationContextPath instead
- new setting app.maxFeedCapacity for deleting old entries
- ability to set filtering expressions for subscriptions to automatically mark new entries as read based on title, content, author or url.
- ability to use !keyword or -keyword to exclude a keyword from a search query
- facebook feeds now show user favicon instead of facebook favicon
- new dark theme 'nightsky'
v 2.0.3
- internet explorer ajax cache workaround
- categories are now deletable again

View File

@@ -1,27 +1,37 @@
CommaFeed [![Build Status](https://travis-ci.org/Athou/commafeed.svg?branch=master)](https://travis-ci.org/Athou/commafeed)
=========
# CommaFeed [![Build Status](https://travis-ci.org/Athou/commafeed.svg?branch=master)](https://travis-ci.org/Athou/commafeed)
Sources for [CommaFeed.com](http://www.commafeed.com/).
Google Reader inspired self-hosted RSS reader, based on Dropwizard and AngularJS.
Related open-source projects
----------------------------
## Related open-source projects
Android apps: [News+ extension](https://github.com/Athou/commafeed-newsplus) - [Android app](https://github.com/doomrobo/CommaFeed-Android-Reader)
Browser extensions: [Chrome](https://github.com/Athou/commafeed-chrome) - [Firefox](https://github.com/Athou/commafeed-firefox) - [Opera](https://github.com/Athou/commafeed-opera) - [Safari](https://github.com/Athou/commafeed-safari)
Deployment on your own server
-----------------------------
## Deployment on your own server
### The short version
git clone https://github.com/Athou/commafeed.git
cd commafeed
mvn clean package
cp config.yml.example config.yml
vi config.yml
java -jar target/commafeed.jar server config.yml
### The long version
CommaFeed 2.0 has been rewritten to use Dropwizard and gulp instead of using tomee and wro4j. The latest version of the 1.x branch is available [here](https://github.com/Athou/commafeed/tree/1.x).
For storage, you can either use an embedded H2 database or an external MySQL, PostgreSQL or SQLServer database.
For storage, you can either use an embedded H2 database (use it only to test CommaFeed) or an external MySQL, PostgreSQL or SQLServer database.
You also need Maven 3.x (and a Java 1.7+ JDK) installed in order to build the application.
To install maven and openjdk on Ubuntu, issue the following commands
sudo apt-get install build-essential openjdk-7-jdk maven
sudo apt-get install g++ build-essential openjdk-7-jdk maven
# Make sure java7 is the selected java version
sudo update-alternatives --config java
sudo update-alternatives --config javac
@@ -45,8 +55,7 @@ Issue the following command to run the app, the server will listen by default on
You can use a proxy http server such as nginx or apache.
Deployment on OpenShift
-----------------------------
## Deployment on OpenShift
[OpenShift](https://openshift.redhat.com) is Red Hat's Platform-as-a-Service (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment. CommaFeed runs perfectly on OpenShift and can even be used in the free tier. Follow the [Getting Started](https://developers.openshift.com/en/getting-started-overview.html) guide and after you sign up and install the Command Line Tools (RHC), do:
@@ -56,8 +65,7 @@ Deployment on OpenShift
git pull -s recursive -X theirs upstream master
git push
Translate CommaFeed into your language
--------------------------------------
## Translate CommaFeed into your language
Files for internationalization are located [here](https://github.com/Athou/commafeed/tree/master/src/main/app/i18n).
@@ -65,8 +73,7 @@ To add a new language, create a new file in that directory.
The name of the file should be the two-letters [ISO-639-1 language code](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
The language has to be referenced in the `src/main/app/js/i18n.js` file to be picked up.
Themes
---------------------
## Themes
To create a theme, create a new file `src/main/webapp/sass/themes/_<theme>.scss`. Your styles should be wrapped in a `#theme-<theme>` element and use the [SCSS format](http://sass-lang.com/) which is a superset of CSS.
@@ -75,8 +82,7 @@ Don't forget to reference your theme in `src/main/webapp/sass/app.scss` and in `
See [_test.scss](https://github.com/Athou/commafeed/blob/master/src/main/webapp/sass/themes/_test.scss) for an example.
Local development
-----------------
## Local development
Steps to configuring a development environment for CommaFeed may include, but may not be limited to:
@@ -100,8 +106,7 @@ Steps to configuring a development environment for CommaFeed may include, but ma
14. When you're done developing, create a fork at the top of https://github.com/Athou/CommaFeed page and commit your changes to it.
15. If you'd like to contribute to CommaFeed, create a pull request from your repository to https://github.com/Athou/CommaFeed when your changes are ready. There's a button to do so at the top of https://github.com/Athou/CommaFeed.
Copyright and license
---------------------
## Copyright and license
Copyright 2013-2014 CommaFeed.

View File

@@ -2,32 +2,36 @@
"name": "commafeed",
"version": "2.0.0",
"dependencies": {
"jquery": "1.11.0",
"jquery": "2.1.1",
"jquery-ui": "1.10.3",
"jquery-mousewheel": "3.1.12",
"lodash": "2.4.1",
"bootstrap": "3.1.1",
"bootstrap": "3.3.1",
"font-awesome": "3.2.1",
"angular": "1.2.16",
"angular-resource": "1.2.16",
"angular-route": "1.2.16",
"angular-sanitize": "1.2.16",
"angular-touch": "1.2.16",
"angular-animate": "1.2.16",
"angular-ui-router": "0.2.8",
"angular": "1.3.2",
"angular-resource": "1.3.2",
"angular-route": "1.3.2",
"angular-sanitize": "1.3.2",
"angular-touch": "1.3.2",
"angular-animate": "1.3.2",
"angular-ui-router": "0.2.12",
"angular-ui-utils": "0.1.0",
"angular-ui-select2": "0.0.5",
"angular-bootstrap": "0.2.0",
"angular-loading-bar": "0.5.0",
"angular-translate": "2.2.0",
"angular-translate-loader-static-files": "2.2.0",
"angular-loading-bar": "0.6.0",
"angular-translate": "2.4.2",
"angular-translate-loader-static-files": "2.4.2",
"ngInfiniteScroll": "1.0.0",
"ng-grid": "2.0.6",
"mousetrap": "1.4.6",
"momentjs": "2.6.0",
"device.js": "matthewhudson/device.js#2ae5c775e35ccc837589e5af34e292c54936778c",
"momentjs": "2.8.3",
"devicejs": "0.1.16",
"readabilicons": "arc90/readability-readabilicons#34c55561c5b8ec6e90714b50237c06b13cb9d59c",
"zocial": "samcollins/css-social-buttons#1f59ecacde475e563fb6771667597493ec4eecb6",
"swagger-ui": "2.0.21"
"swagger-ui": "2.0.24"
},
"resolutions": {
"angular": "1.3.2",
"angular-translate": "2.4.2"
}
}

View File

@@ -1,15 +1,15 @@
# CommaFeed settings
# ------------------
app:
# context path of the application
contextPath: /
# url used to access commafeed
publicUrl: http://localhost:8082/
# wether to allow user registrations
allowRegistrations: true
# create a demo account the first time the app starts
createDemoAccount: false
# put your google analytics tracking code here
googleAnalyticsTrackingCode:
@@ -47,6 +47,9 @@ app:
# time to keep unread statuses (in days), 0 to disable
keepStatusDays: 0
# entries to keep per feed, old entries will be deleted, 0 to disable
maxFeedCapacity: 500
# cache service to use, possible values are 'noop' and 'redis'
cache: noop
@@ -69,7 +72,7 @@ app:
database:
driverClass: org.h2.Driver
url: jdbc:h2:./target/example
url: jdbc:h2:./target/example;mv_store=false
user: sa
password: sa
properties:
@@ -94,7 +97,7 @@ logging:
loggers:
com.commafeed: DEBUG
liquibase: INFO
org.hibernate.SQL: ALL
org.hibernate.SQL: INFO # or ALL for sql debugging
org.hibernate.engine.internal.StatisticalLoggingSessionEventListener: WARN
appenders:
- type: console

View File

@@ -1,15 +1,15 @@
# CommaFeed settings
# ------------------
app:
# context path of the application
contextPath: /
# url used to access commafeed
publicUrl: http://localhost:8082/
# wether to allow user registrations
allowRegistrations: false
# create a demo account the first time the app starts
createDemoAccount: false
# put your google analytics tracking code here
googleAnalyticsTrackingCode:
@@ -25,6 +25,7 @@ app:
smtpTls: false
smtpUserName:
smtpPassword:
smtpFromAddress:
# wether this commafeed instance has a lot of feeds to refresh
# leave this to false in almost all cases
@@ -47,6 +48,9 @@ app:
# time to keep unread statuses (in days), 0 to disable
keepStatusDays: 0
# entries to keep per feed, old entries will be deleted, 0 to disable
maxFeedCapacity: 500
# cache service to use, possible values are 'noop' and 'redis'
cache: noop
@@ -69,7 +73,7 @@ app:
database:
driverClass: org.h2.Driver
url: jdbc:h2:/home/commafeed/db
url: jdbc:h2:/home/commafeed/db;mv_store=false
user: sa
password: sa
properties:

View File

@@ -72,7 +72,7 @@ gulp.task('build-dev', ['images', 'i18n', 'favicons', 'sass', 'fonts', 'select2'
var jsFilter = filter("**/*.js");
var cssFilter = filter("**/*.css");
return gulp.src([SRC_DIR + 'index.html', TEMP_DIR + 'app.css']).pipe(assets).pipe(rev()).pipe(assets.restore()).pipe(useref()).pipe(
revReplace()).pipe(gulp.dest(BUILD_DIR));
revReplace()).pipe(gulp.dest(BUILD_DIR)).pipe(connect.reload());
});
gulp.task('build', ['images', 'i18n', 'favicons', 'sass', 'fonts', 'select2', 'swagger-ui', 'template-cache', 'bower'], function() {
@@ -101,6 +101,7 @@ gulp.task('serve', function() {
connect.server({
root : BUILD_DIR,
port : 8082,
livereload: true,
middleware : function() {
var rest = '^/rest/(.*)$ http://localhost:8083/rest/$1 [P]';
var next = '^/next(.*)$ http://localhost:8083/next$1 [P]';

View File

@@ -4,17 +4,17 @@
"main": "main.js",
"private": true,
"devDependencies": {
"gulp": "3.8.7",
"gulp-rev": "1.0.0",
"gulp-rev-replace": "0.3.0",
"gulp-minify-css": "0.3.7",
"gulp-uglify": "0.3.1",
"gulp-filter": "1.0.0",
"gulp-bower": "0.0.6",
"gulp-connect": "2.0.6",
"connect-modrewrite": "0.7.7",
"gulp-sass": "0.7.2",
"gulp-useref": "0.6.0",
"gulp-angular-templatecache": "1.3.0"
"gulp": "3.8.10",
"gulp-rev": "2.0.1",
"gulp-rev-replace": "0.3.1",
"gulp-minify-css": "0.3.11",
"gulp-uglify": "1.0.1",
"gulp-filter": "1.0.2",
"gulp-bower": "0.0.7",
"gulp-connect": "2.2.0",
"connect-modrewrite": "0.7.9",
"gulp-sass": "1.1.0",
"gulp-useref": "1.0.2",
"gulp-angular-templatecache": "1.4.2"
}
}

82
pom.xml
View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.commafeed</groupId>
<artifactId>commafeed</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
<packaging>jar</packaging>
<name>CommaFeed</name>
@@ -14,9 +14,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dropwizard.version>0.7.1</dropwizard.version>
<guice.version>3.0</guice.version>
<querydsl.version>3.5.0</querydsl.version>
<java.version>1.7</java.version>
<dropwizard.version>0.8.0-rc1</dropwizard.version>
<guice.version>4.0-beta5</guice.version>
<querydsl.version>3.6.0</querydsl.version>
<rome.version>1.5.0</rome.version>
</properties>
@@ -38,10 +39,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
@@ -98,7 +99,7 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.16</version>
<version>0.0.19</version>
<executions>
<execution>
<id>install node and npm</id>
@@ -139,29 +140,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.jamierf.dropwizard</groupId>
<artifactId>dropwizard-debpkg-maven-plugin</artifactId>
<version>0.7</version>
<configuration>
<configTemplate>${basedir}/config.yml.example</configTemplate>
<jvm>
<packageName>openjdk-7-jdk</packageName>
<server>true</server>
</jvm>
<unix>
<user>commafeed</user>
</unix>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dwpackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -178,6 +156,12 @@
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
@@ -209,6 +193,12 @@
<artifactId>dropwizard-migrations</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<!-- TODO remove when dropwizard 0.8.0 is released -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
@@ -220,19 +210,23 @@
<version>${dropwizard.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.10</version>
<version>1.3.11</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
@@ -245,7 +239,7 @@
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@@ -259,25 +253,25 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
@@ -294,9 +288,9 @@
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
<artifactId>juniversalchardet</artifactId>
<version>1.0.3</version>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>54.1.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cssparser</groupId>
@@ -312,7 +306,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.33</version>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
@@ -328,7 +322,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -98,6 +98,8 @@
"next_refresh" : "Next refresh",
"queued_for_refresh" : "Queued for refresh",
"feed_url" : "Feed URL",
"filtering_expression" : "Filtering expression",
"filtering_expression_help" : "If not empty, an expression evaluating to 'true' or 'false'. If false, new entries for this feed will be marked as read automatically.\nAvailable variables are 'title', 'content', 'url' and 'author' and their content is converted to lower case to ease string comparison.\nExample: url.contains('youtube') or (author eq 'athou' and title.contains('github').\nComplete available syntax is available <a href='http://commons.apache.org/proper/commons-jexl/reference/syntax.html' target='_blank'>here</a>.",
"generate_api_key_first" : "Generate an API key in your profile first.",
"unsubscribe" : "Unsubscribe",
"unsubscribe_confirmation" : "Are you sure you want to unsubscribe from this feed?",

View File

@@ -12,7 +12,9 @@
<link rel="icon" sizes="32x32" href="app-icon-32.png" />
<link rel="icon" sizes="64x64" href="app-icon-64.png" />
<link rel="icon" sizes="128x128" href="app-icon-128.png" />
<link rel="icon" sizes="192x192" href="app-icon-192.png" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<meta name="theme-color" content="#F88A14" />
<meta name="application-name" content="CommaFeed" />
<meta name="msapplication-navbutton-color" content="#F88A14" />
<meta name="msapplication-starturl" content="/" />
@@ -62,8 +64,8 @@
<script type="text/javascript" src="lib/angular-ui-select2/src/select2.js"></script>
<script type="text/javascript" src="lib/select2/select2.js"></script>
<script type="text/javascript" src="lib/mousetrap/mousetrap.js"></script>
<script type="text/javascript" src="lib/momentjs/min/moment-with-langs.js"></script>
<script type="text/javascript" src="lib/device.js/lib/device.js"></script>
<script type="text/javascript" src="lib/momentjs/min/moment-with-locales.js"></script>
<script type="text/javascript" src="lib/devicejs/lib/device.js"></script>
<script type="text/javascript" src="js/controllers.js"></script>
<script type="text/javascript" src="js/directives.js"></script>

View File

@@ -322,17 +322,21 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
$scope.save = function() {
var sub = $scope.sub;
$scope.error = null;
FeedService.modify({
id : sub.id,
name : sub.name,
position : sub.position,
categoryId : sub.categoryId
categoryId : sub.categoryId,
filter : sub.filter
}, function() {
CategoryService.init();
$state.transitionTo('feeds.view', {
_id : 'all',
_type : 'category'
});
}, function(e) {
$scope.error = e.data;
});
};
}]);
@@ -489,6 +493,7 @@ module.controller('ToolbarCtrl', [
type : $stateParams._type,
id : $stateParams._id,
olderThan : olderThan,
keywords : $location.search().q,
read : true
});
};
@@ -881,6 +886,7 @@ module.controller('FeedListCtrl', [
service.mark({
id : $scope.selectedId,
olderThan : olderThan || $scope.timestamp,
keywords : $location.search().q,
read : true
}, function() {
CategoryService.refresh(function() {
@@ -1365,7 +1371,7 @@ module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', 'An
$scope.langs = LangService.langs;
$scope.themes = ['default', 'bootstrap', 'dark', 'ebraminio', 'MRACHINI', 'svetla', 'third'];
$scope.themes = ['default', 'bootstrap', 'dark', 'ebraminio', 'MRACHINI', 'nightsky', 'svetla', 'third'];
$scope.settingsService = SettingsService;
$scope.$watch('settingsService.settings', function(value) {

View File

@@ -72,7 +72,7 @@ module.directive('tags', function() {
tags : []
};
if (newValue) {
data.tags = newValue.split(',');
data.tags = newValue;
}
EntryService.tag(data);
}

View File

@@ -23,26 +23,23 @@ app.config([
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|javascript):/);
var interceptor = ['$rootScope', '$q', '$injector', function(scope, $q, $injector) {
var success = function(response) {
var f = {};
f.response = function(response) {
return response;
};
var error = function(response) {
f.responseError = function(response) {
var status = response.status;
if (status == 401) {
$injector.get('$state').transitionTo('welcome');
}
return $q.reject(response);
};
var promise = function(promise) {
return promise.then(success, error);
};
return promise;
return f;
}];
$httpProvider.responseInterceptors.push(interceptor);
$httpProvider.interceptors.push(interceptor);
$stateProvider.state('feeds', {
'abstract' : true,

View File

@@ -62,7 +62,7 @@ module.factory('SettingsService', ['$resource', '$translate', function($resource
} else if (lang === 'ms') {
lang = 'ms-my';
}
moment.lang(lang, {});
moment.locale(lang, {});
if (callback) {
callback(data);
}
@@ -298,6 +298,7 @@ module.factory('EntryService', ['$resource', '$http', function($resource, $http)
$http.get('rest/entry/tags').success(function(data) {
res.tags = [];
res.tags.push.apply(res.tags, data);
res.tags.sort();
});
};
var oldTag = res.tag;

View File

@@ -17,6 +17,7 @@
@import "themes/bootstrap";
@import "themes/ebraminio";
@import "themes/MRACHINI";
@import "themes/nightsky";
@import "themes/svetla";
@import "themes/dark";
@import "themes/third";

View File

@@ -13,8 +13,4 @@
content: "\e018";
font-family: "readabilicons";
-webkit-font-smoothing: antialiased;
font-size: 21px;
top: 5px;
position: relative;
line-height: 0px;
}

View File

@@ -1,3 +1,8 @@
a:focus {
outline: none;
text-decoration: none;
}
.container-full {
width: 100%;
margin: 0 auto;
@@ -43,6 +48,10 @@ label {
display: block;
}
.pre-wrap {
white-space: pre-wrap;
}
.form-horizontal .control-group {
margin-bottom: 10px;
}
@@ -116,19 +125,23 @@ blockquote p {
font-size: 14px;
}
.btn,.btn-large,.btn-small,.btn-mini {
.form-group {
margin-bottom: 10px;
}
.btn, .btn-large, .btn-small, .btn-mini {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}
.btn-group>.btn:first-child,.btn-group>.btn-large:first-child {
.btn-group>.btn:first-child, .btn-group>.btn-large:first-child {
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}
.btn-group>.btn:last-child,.btn-group>.btn-large:last-child,.btn-group>.dropdown-toggle
.btn-group>.btn:last-child, .btn-group>.btn-large:last-child, .btn-group>.dropdown-toggle
{
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;

View File

@@ -0,0 +1,126 @@
#theme-nightsky {
a {
color: #2A9FD6;
}
.nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus {
color: #FFF;
background-color: #2A9FD6;
}
body, .toolbar {
color: #C6C6C6;
background-color: #2F2F2F;
}
.btn-default {
color: #C6C6C6;
background-color: #424242;
border-color: #424242;
}
.btn-default:hover, .btn-default:focus, .btn-default.focus, .btn-default:active,
.btn-default.active, .open>.dropdown-toggle.btn-default {
background-color: #282828;
border-color: #232323;
}
.css-treeview li .tree-item:hover {
background-color: #282828;
}
.css-treeview .unread-counter {
color: #939393;
}
.css-treeview .category-link, .css-treeview a {
color: #939393;
}
.css-treeview a .unread, .css-treeview .category-link .unread {
color: #C6C6C6;
}
.css-treeview .selected {
color: #C00;
}
.entrylist-header {
border-bottom: 1px solid #282828;
}
#feed-accordion .entry {
border-bottom: 1px solid #282828;
}
#feed-accordion .entry-body .entry-title {
font-weight: normal;
}
#feed-accordion .entry-heading .entry-name {
color: #939393;
}
#feed-accordion .unread .entry-heading .entry-name {
font-weight: normal;
color: #C6C6C6;
}
#feed-accordion .unread .entry-heading {
background-color: #444;
}
#feed-accordion .entry-heading {
background-color: #2F2F2F;
}
#feed-accordion .unread .entry-heading:hover {
background-color: #2F2F2F;
}
#feed-accordion .current.closed .entry-heading {
background-color: #151515;
}
#feed-accordion .entry-heading-link {
color: #C6C6C6;
}
#feed-accordion .entry-external-link {
color: #C6C6C6;
}
#feed-accordion .icon-star-empty {
color: #C6C6C6;
}
#feed-accordion .entry-heading .feed-name {
color: #939393;
}
#feed-accordion .entry-body-content {
color: #C6C6C6;
}
#feed-accordion .entry-buttons {
background-color: #494949;
border-top: 1px solid #282828;
}
#feed-accordion .share-buttons a {
color: #C6C6C6;
}
#feed-accordion a.mark-up-to {
color: #C6C6C6;
}
#loading-bar .bar {
background: #C6C6C6;
}
#loading-bar .peg {
box-shadow: 0 0 10px #C6C6C6, 0 0 5px #C6C6C6;
}
}

View File

@@ -6,7 +6,7 @@
<button type="button" class="close" ng-click="close()">&times;</button>
<h4>
<input ng-model="filter" class="filter-input"
ui-keydown="{'up': 'focusPrevious($event)', 'down': 'focusNext($event)', 'enter': 'openFocused()' }" placeholder="'feedsearch.hint' | translate"
ui-keydown="{'up': 'focusPrevious($event)', 'down': 'focusNext($event)', 'enter': 'openFocused()' }" placeholder="{{'feedsearch.hint' | translate}}"
focus="feedSearchModal">
</h4>
<small>{{ 'feedsearch.help' | translate }}</small>

View File

@@ -1,12 +1,12 @@
<span>
<a ng-click="edit_mode=!edit_mode" class="nolink pointer">
<span ng-click="edit_mode=!edit_mode" class="nolink pointer">
<i class="icon-tags"></i>
{{ 'global.tags' | translate }}
</a>
</span>
<span ng-if="!edit_mode">
<span class="label label-info" ng-repeat="tag in entry.tags">{{tag}}</span>
</span>
<span ng-if="edit_mode">
<input type="text" ui-select2="select2Options" ng-model="entry.tags" class="tag-input" autofocus />
<input type="hidden" ui-select2="select2Options" ng-model="entry.tags" class="tag-input" autofocus />
</span>
</span>

View File

@@ -124,9 +124,9 @@
</form>
</div>
<div class="btn-group donate">
<a class="btn btn-success" type="button" ng-click="toHelp()" title="{{ 'toolbar.about' | translate }} / {{ 'toolbar.donate' | translate }}">
<button class="btn btn-success" type="button" ng-click="toHelp()" title="{{ 'toolbar.about' | translate }} / {{ 'toolbar.donate' | translate }}">
<i class="icon-info-sign"></i>
</a>
</button>
</div>
</div>

View File

@@ -30,7 +30,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.feed_url' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<a ng-show="user.apiKey" href="{{'rest/category/entriesAsFeed?id=' + category.id + '&apiKey=' + user.apiKey}}" target="_blank">{{ 'global.link' | translate }}</a>
<span ng-show="!user.apiKey">{{ 'details.generate_api_key_first' | translate }}</span>
</div>

View File

@@ -3,15 +3,16 @@
<h3>{{ 'details.feed_details' | translate }}</h3>
</div>
<form name="form" class="form-horizontal" ng-submit="save()">
<div class="alert alert-danger" ng-if="error">{{ error }}</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.url' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<a href="{{sub.feedUrl}}" target="_blank">{{sub.feedUrl}}</a>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.website' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<a href="{{sub.feedLink}}" target="_blank">{{sub.feedLink}}</a>
</div>
</div>
@@ -49,26 +50,34 @@
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.next_refresh' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<span>{{sub.nextRefresh|entryDate:('details.queued_for_refresh' | translate) }}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.message' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<span>{{sub.message}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.feed_url' | translate }}</label>
<div class="col-sm-10 checkbox">
<div class="col-sm-10 form-control-static">
<a ng-show="user.apiKey" href="{{'rest/feed/entriesAsFeed?id=' + sub.id + '&apiKey=' + user.apiKey}}" target="_blank">{{ 'global.link' | translate }}</a>
<span ng-show="!user.apiKey">{{ 'details.generate_api_key_first' | translate }}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'details.filtering_expression' | translate }}</label>
<div class="col-sm-10">
<input type="text" name="filter" ng-model="sub.filter" class="form-control"></input>
<p class="help-block pre-wrap" ng-bind-html="'details.filtering_expression_help' | translate"></p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">{{ 'global.save' | translate }}</button>

View File

@@ -5,6 +5,7 @@ import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.hibernate.HibernateBundle;
import io.dropwizard.migrations.MigrationsBundle;
import io.dropwizard.server.DefaultServerFactory;
import io.dropwizard.servlets.CacheBustingFilter;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
@@ -12,6 +13,7 @@ import io.dropwizard.setup.Environment;
import java.io.IOException;
import java.util.Date;
import java.util.EnumSet;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import javax.servlet.DispatcherType;
@@ -22,6 +24,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.server.session.SessionHandler;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.hibernate.cfg.AvailableSettings;
import com.commafeed.backend.feed.FeedRefreshTaskGiver;
import com.commafeed.backend.feed.FeedRefreshUpdater;
@@ -39,10 +43,8 @@ import com.commafeed.backend.model.UserRole;
import com.commafeed.backend.model.UserSettings;
import com.commafeed.backend.service.StartupService;
import com.commafeed.backend.service.UserService;
import com.commafeed.backend.task.OldStatusesCleanupTask;
import com.commafeed.backend.task.OrphansCleanupTask;
import com.commafeed.frontend.auth.SecurityCheckProvider;
import com.commafeed.frontend.auth.SecurityCheckProvider.SecurityCheckUserServiceProvider;
import com.commafeed.backend.task.ScheduledTask;
import com.commafeed.frontend.auth.SecurityCheckFactoryProvider;
import com.commafeed.frontend.resource.AdminREST;
import com.commafeed.frontend.resource.CategoryREST;
import com.commafeed.frontend.resource.EntryREST;
@@ -54,10 +56,11 @@ import com.commafeed.frontend.servlet.AnalyticsServlet;
import com.commafeed.frontend.servlet.CustomCssServlet;
import com.commafeed.frontend.servlet.LogoutServlet;
import com.commafeed.frontend.servlet.NextUnreadServlet;
import com.commafeed.frontend.session.SessionHelperProvider;
import com.commafeed.frontend.session.SessionHelperFactoryProvider;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.sun.jersey.api.core.ResourceConfig;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.wordnik.swagger.config.ConfigFactory;
import com.wordnik.swagger.config.ScannerFactory;
import com.wordnik.swagger.config.SwaggerConfig;
@@ -89,14 +92,18 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
FeedSubscription.class, User.class, UserRole.class, UserSettings.class) {
@Override
public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configuration) {
return configuration.getDatabase();
DataSourceFactory factory = configuration.getDataSourceFactory();
// keep using old id generator for backward compatibility
factory.getProperties().put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false");
return factory;
}
});
bootstrap.addBundle(new MigrationsBundle<CommaFeedConfiguration>() {
@Override
public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configuration) {
return configuration.getDatabase();
return configuration.getDataSourceFactory();
}
});
@@ -105,20 +112,20 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
@Override
public void run(CommaFeedConfiguration config, Environment environment) throws Exception {
// configure context path
environment.getApplicationContext().setContextPath(config.getApplicationSettings().getContextPath());
// guice init
Injector injector = Guice.createInjector(new CommaFeedModule(hibernateBundle.getSessionFactory(), config, environment.metrics()));
// Auth/session management
// session management
environment.servlets().setSessionHandler(new SessionHandler(config.getSessionManagerFactory().build()));
environment.jersey().register(new SecurityCheckUserServiceProvider(injector.getInstance(UserService.class)));
environment.jersey().register(SecurityCheckProvider.class);
environment.jersey().register(SessionHelperProvider.class);
// support for "@SecurityCheck User user" injection
environment.jersey().register(new SecurityCheckFactoryProvider.Binder(injector.getInstance(UserService.class)));
// support for "@Context SessionHelper sessionHelper" injection
environment.jersey().register(new SessionHelperFactoryProvider.Binder());
// REST resources
environment.jersey().setUrlPattern("/rest/*");
((DefaultServerFactory) config.getServerFactory()).setJerseyRootPath("/rest/*");
environment.jersey().register(injector.getInstance(AdminREST.class));
environment.jersey().register(injector.getInstance(CategoryREST.class));
environment.jersey().register(injector.getInstance(EntryREST.class));
@@ -127,6 +134,9 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
environment.jersey().register(injector.getInstance(ServerREST.class));
environment.jersey().register(injector.getInstance(UserREST.class));
// @FormDataParam support
environment.jersey().register(MultiPartFeature.class);
// Servlets
environment.servlets().addServlet("next", injector.getInstance(NextUnreadServlet.class)).addMapping("/next");
environment.servlets().addServlet("logout", injector.getInstance(LogoutServlet.class)).addMapping("/logout");
@@ -134,9 +144,13 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
environment.servlets().addServlet("analytics.js", injector.getInstance(AnalyticsServlet.class)).addMapping("/analytics.js");
// Scheduled tasks
ScheduledExecutorService executor = environment.lifecycle().scheduledExecutorService("task-scheduler").build();
injector.getInstance(OldStatusesCleanupTask.class).register(executor);
injector.getInstance(OrphansCleanupTask.class).register(executor);
Set<ScheduledTask> tasks = injector.getInstance(Key.get(new TypeLiteral<Set<ScheduledTask>>() {
}));
ScheduledExecutorService executor = environment.lifecycle().scheduledExecutorService("task-scheduler", true).threads(tasks.size())
.build();
for (ScheduledTask task : tasks) {
task.register(executor);
}
// database init/changelogs
environment.lifecycle().manage(injector.getInstance(StartupService.class));
@@ -170,8 +184,6 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
}
}).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/rest/*");
// enable wadl
environment.jersey().disable(ResourceConfig.FEATURE_DISABLE_WADL);
}
public static void main(String[] args) throws Exception {

View File

@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
import lombok.Getter;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.validator.constraints.NotBlank;
import com.commafeed.backend.cache.RedisPoolFactory;
@@ -35,7 +35,7 @@ public class CommaFeedConfiguration extends Configuration {
@Valid
@NotNull
@JsonProperty("database")
private DataSourceFactory database = new DataSourceFactory();
private DataSourceFactory dataSourceFactory = new DataSourceFactory();
@Valid
@NotNull
@@ -64,60 +64,74 @@ public class CommaFeedConfiguration extends Configuration {
public static class ApplicationSettings {
@NotNull
@NotBlank
private String contextPath;
@NotNull
@NotBlank
@Valid
private String publicUrl;
@NotNull
private boolean allowRegistrations;
@Valid
private Boolean allowRegistrations;
@NotNull
@Valid
private Boolean createDemoAccount;
private String googleAnalyticsTrackingCode;
@NotNull
@Min(1)
private int backgroundThreads;
@Valid
private Integer backgroundThreads;
@NotNull
@Min(1)
private int databaseUpdateThreads;
@Valid
private Integer databaseUpdateThreads;
private String smtpHost;
private int smtpPort;
private boolean smtpTls;
private String smtpUserName;
private String smtpPassword;
private String smtpFromAddress;
@NotNull
private boolean heavyLoad;
@Valid
private Boolean heavyLoad;
@NotNull
private boolean pubsubhubbub;
@Valid
private Boolean pubsubhubbub;
@NotNull
private boolean imageProxyEnabled;
@Valid
private Boolean imageProxyEnabled;
@NotNull
@Min(0)
private int queryTimeout;
@Valid
private Integer queryTimeout;
@NotNull
@Min(0)
private int keepStatusDays;
@Valid
private Integer keepStatusDays;
@NotNull
@Min(0)
private int refreshIntervalMinutes;
@Valid
private Integer maxFeedCapacity;
@NotNull
@Min(0)
@Valid
private Integer refreshIntervalMinutes;
@NotNull
@Valid
private CacheType cache;
@NotNull
@Valid
private String announcement;
public Date getUnreadThreshold() {

View File

@@ -11,9 +11,15 @@ import com.commafeed.CommaFeedConfiguration.CacheType;
import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.cache.NoopCacheService;
import com.commafeed.backend.cache.RedisCacheService;
import com.commafeed.backend.favicon.DefaultFaviconFetcher;
import com.commafeed.backend.favicon.AbstractFaviconFetcher;
import com.commafeed.backend.favicon.DefaultFaviconFetcher;
import com.commafeed.backend.favicon.FacebookFaviconFetcher;
import com.commafeed.backend.favicon.YoutubeFaviconFetcher;
import com.commafeed.backend.task.OldEntriesCleanupTask;
import com.commafeed.backend.task.OldStatusesCleanupTask;
import com.commafeed.backend.task.OrphanedContentsCleanupTask;
import com.commafeed.backend.task.OrphanedFeedsCleanupTask;
import com.commafeed.backend.task.ScheduledTask;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.multibindings.Multibinder;
@@ -38,8 +44,15 @@ public class CommaFeedModule extends AbstractModule {
log.info("using cache {}", cacheService.getClass());
bind(CacheService.class).toInstance(cacheService);
Multibinder<AbstractFaviconFetcher> multibinder = Multibinder.newSetBinder(binder(), AbstractFaviconFetcher.class);
multibinder.addBinding().to(YoutubeFaviconFetcher.class);
multibinder.addBinding().to(DefaultFaviconFetcher.class);
Multibinder<AbstractFaviconFetcher> faviconMultibinder = Multibinder.newSetBinder(binder(), AbstractFaviconFetcher.class);
faviconMultibinder.addBinding().to(YoutubeFaviconFetcher.class);
faviconMultibinder.addBinding().to(FacebookFaviconFetcher.class);
faviconMultibinder.addBinding().to(DefaultFaviconFetcher.class);
Multibinder<ScheduledTask> taskMultibinder = Multibinder.newSetBinder(binder(), ScheduledTask.class);
taskMultibinder.addBinding().to(OldStatusesCleanupTask.class);
taskMultibinder.addBinding().to(OldEntriesCleanupTask.class);
taskMultibinder.addBinding().to(OrphanedFeedsCleanupTask.class);
taskMultibinder.addBinding().to(OrphanedContentsCleanupTask.class);
}
}

View File

@@ -17,7 +17,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -53,11 +53,14 @@ public class HttpGetter {
private static final String ACCEPT_LANGUAGE = "en";
private static final String PRAGMA_NO_CACHE = "No-cache";
private static final String CACHE_CONTROL_NO_CACHE = "no-cache";
private static final HttpResponseInterceptor REMOVE_INCORRECT_CONTENT_ENCODING = new ContentEncodingInterceptor();
private static SSLContext SSL_CONTEXT = null;
static {
// fix for "handshake alert: unrecognized_name"
System.setProperty("jsse.enableSNIExtension", "false");
try {
SSL_CONTEXT = SSLContext.getInstance("TLS");
SSL_CONTEXT.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom());

View File

@@ -2,7 +2,7 @@ package com.commafeed.backend.cache;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

View File

@@ -1,11 +1,11 @@
package com.commafeed.backend.dao;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang.ObjectUtils;
import org.hibernate.SessionFactory;
import com.commafeed.backend.model.FeedCategory;
@@ -70,7 +70,7 @@ public class FeedCategoryDAO extends GenericDAO<FeedCategory> {
}
boolean isChild = false;
while (child != null) {
if (ObjectUtils.equals(child.getId(), parent.getId())) {
if (Objects.equals(child.getId(), parent.getId())) {
isChild = true;
break;
}

View File

@@ -7,7 +7,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
import com.commafeed.backend.model.Feed;

View File

@@ -1,20 +1,23 @@
package com.commafeed.backend.dao;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.codec.digest.DigestUtils;
import org.hibernate.SessionFactory;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.QFeed;
import com.commafeed.backend.model.QFeedEntry;
import com.commafeed.backend.model.QFeedSubscription;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.mysema.query.Tuple;
import com.mysema.query.types.expr.NumberExpression;
@Singleton
public class FeedEntryDAO extends GenericDAO<FeedEntry> {
@@ -32,17 +35,27 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
return Iterables.getFirst(list, null);
}
public List<FeedEntry> findWithoutSubscriptions(int max) {
QFeed feed = QFeed.feed;
QFeedSubscription sub = QFeedSubscription.feedSubscription;
return newQuery().from(entry).join(entry.feed, feed).leftJoin(feed.subscriptions, sub).where(sub.id.isNull()).limit(max)
.list(entry);
public List<FeedCapacity> findFeedsExceedingCapacity(long maxCapacity, long max) {
List<FeedCapacity> list = Lists.newArrayList();
NumberExpression<Long> count = entry.id.countDistinct();
List<Tuple> tuples = newQuery().from(entry).groupBy(entry.feed).having(count.gt(maxCapacity)).limit(max).list(entry.feed.id, count);
for (Tuple tuple : tuples) {
list.add(new FeedCapacity(tuple.get(entry.feed.id), tuple.get(count)));
}
return list;
}
public int delete(Date olderThan, int max) {
List<FeedEntry> list = newQuery().from(entry).where(entry.inserted.lt(olderThan)).limit(max).list(entry);
public int deleteOldEntries(Long feedId, long max) {
List<FeedEntry> list = newQuery().from(entry).where(entry.feed.id.eq(feedId)).orderBy(entry.updated.asc()).limit(max).list(entry);
int deleted = list.size();
delete(list);
return deleted;
}
@AllArgsConstructor
@Getter
public static class FeedCapacity {
private Long id;
private Long capacity;
}
}

View File

@@ -7,12 +7,13 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.hibernate.SessionFactory;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.FixedSizeSortedSet;
import com.commafeed.backend.feed.FeedEntryKeyword;
import com.commafeed.backend.feed.FeedEntryKeyword.Mode;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedEntryTag;
@@ -112,18 +113,21 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
return lazyLoadContent(includeContent, statuses);
}
private HibernateQuery buildQuery(User user, FeedSubscription sub, boolean unreadOnly, String keywords, Date newerThan, int offset,
int limit, ReadingOrder order, Date last, String tag) {
private HibernateQuery buildQuery(User user, FeedSubscription sub, boolean unreadOnly, List<FeedEntryKeyword> keywords, Date newerThan,
int offset, int limit, ReadingOrder order, Date last, String tag) {
HibernateQuery query = newQuery().from(entry).where(entry.feed.eq(sub.getFeed()));
if (keywords != null) {
query.join(entry.content, content);
for (String keyword : StringUtils.split(keywords)) {
for (FeedEntryKeyword keyword : keywords) {
BooleanBuilder or = new BooleanBuilder();
or.or(content.content.containsIgnoreCase(keyword));
or.or(content.title.containsIgnoreCase(keyword));
or.or(content.content.containsIgnoreCase(keyword.getKeyword()));
or.or(content.title.containsIgnoreCase(keyword.getKeyword()));
if (keyword.getMode() == Mode.EXCLUDE) {
or.not();
}
query.where(or);
}
}
@@ -180,8 +184,9 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
return query;
}
public List<FeedEntryStatus> findBySubscriptions(User user, List<FeedSubscription> subs, boolean unreadOnly, String keywords,
Date newerThan, int offset, int limit, ReadingOrder order, boolean includeContent, boolean onlyIds, String tag) {
public List<FeedEntryStatus> findBySubscriptions(User user, List<FeedSubscription> subs, boolean unreadOnly,
List<FeedEntryKeyword> keywords, Date newerThan, int offset, int limit, ReadingOrder order, boolean includeContent,
boolean onlyIds, String tag) {
int capacity = offset + limit;
Comparator<FeedEntryStatus> comparator = order == ReadingOrder.desc ? STATUS_COMPARATOR_DESC : STATUS_COMPARATOR_ASC;
FixedSizeSortedSet<FeedEntryStatus> set = new FixedSizeSortedSet<FeedEntryStatus>(capacity, comparator);

View File

@@ -5,7 +5,7 @@ import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.backend.model.Feed;

View File

@@ -6,7 +6,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

View File

@@ -0,0 +1,79 @@
package com.commafeed.backend.favicon;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import com.commafeed.backend.HttpGetter;
import com.commafeed.backend.HttpGetter.HttpResult;
import com.commafeed.backend.model.Feed;
@Slf4j
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class FacebookFaviconFetcher extends AbstractFaviconFetcher {
private final HttpGetter getter;
@Override
public byte[] fetch(Feed feed) {
String url = feed.getUrl();
if (!url.toLowerCase().contains("www.facebook.com")) {
return null;
}
String userName = extractUserName(url);
if (userName == null) {
return null;
}
String iconUrl = String.format("https://graph.facebook.com/%s/picture?type=square&height=16", userName);
byte[] bytes = null;
String contentType = null;
try {
log.debug("Getting Facebook user's icon, {}", url);
HttpResult iconResult = getter.getBinary(iconUrl, TIMEOUT);
bytes = iconResult.getContent();
contentType = iconResult.getContentType();
} catch (Exception e) {
log.debug("Failed to retrieve Facebook icon", e);
}
if (!isValidIconResponse(bytes, contentType)) {
bytes = null;
}
return bytes;
}
private String extractUserName(String url) {
URI uri = null;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
log.debug("could not parse url", e);
return null;
}
List<NameValuePair> params = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8.name());
for (NameValuePair param : params) {
if ("id".equals(param.getName())) {
return param.getValue();
}
}
return null;
}
}

View File

@@ -50,15 +50,8 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
if (thumbnails.isEmpty()) {
return null;
}
String thumbnailUrl = thumbnails.get(0).attr("abs:url");
int thumbnailStart = thumbnailUrl.indexOf("<media:thumbnail url='");
int thumbnailEnd = thumbnailUrl.indexOf("'/>", thumbnailStart);
if (thumbnailStart != -1) {
thumbnailUrl = thumbnailUrl.substring(thumbnailStart + "<media:thumbnail url='".length(), thumbnailEnd);
}
// final get to actually retrieve the thumbnail
HttpResult iconResult = getter.getBinary(thumbnailUrl, TIMEOUT);
bytes = iconResult.getContent();

View File

@@ -0,0 +1,40 @@
package com.commafeed.backend.feed;
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
/**
* A keyword used in a search query
*/
@Getter
@RequiredArgsConstructor
public class FeedEntryKeyword {
public static enum Mode {
INCLUDE, EXCLUDE;
}
private final String keyword;
private final Mode mode;
public static List<FeedEntryKeyword> fromQueryString(String keywords) {
List<FeedEntryKeyword> list = Lists.newArrayList();
if (keywords != null) {
for (String keyword : StringUtils.split(keywords)) {
boolean not = false;
if (keyword.startsWith("-") || keyword.startsWith("!")) {
not = true;
keyword = keyword.substring(1);
}
list.add(new FeedEntryKeyword(keyword, not ? Mode.EXCLUDE : Mode.INCLUDE));
}
}
return list;
}
}

View File

@@ -45,7 +45,7 @@ public class FeedFetcher {
} catch (FeedException e) {
if (extractFeedUrlFromHtml) {
String extractedUrl = extractFeedUrl(StringUtils.newStringUtf8(result.getContent()), feedUrl);
if (org.apache.commons.lang.StringUtils.isNotBlank(extractedUrl)) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(extractedUrl)) {
feedUrl = extractedUrl;
result = getter.getBinary(extractedUrl, lastModified, eTag, timeout);

View File

@@ -11,8 +11,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang3.StringUtils;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.xml.sax.InputSource;
@@ -173,7 +172,7 @@ public class FeedParser {
if (item.getContents().isEmpty()) {
content = item.getDescription() == null ? null : item.getDescription().getValue();
} else {
content = StringUtils.join(Collections2.transform(item.getContents(), CONTENT_TO_STRING), SystemUtils.LINE_SEPARATOR);
content = StringUtils.join(Collections2.transform(item.getContents(), CONTENT_TO_STRING), System.lineSeparator());
}
return StringUtils.trimToNull(content);
}

View File

@@ -9,7 +9,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.time.DateUtils;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
@@ -154,7 +154,7 @@ public class FeedQueues {
}
private Date getLastLoginThreshold() {
if (config.getApplicationSettings().isHeavyLoad()) {
if (config.getApplicationSettings().getHeavyLoad()) {
return DateUtils.addDays(new Date(), -30);
} else {
return null;

View File

@@ -37,7 +37,14 @@ public class FeedRefreshExecutor {
return offerLast(r);
}
}
});
}) {
@Override
protected void afterExecute(Runnable r, Throwable t) {
if (t != null) {
log.error("thread from pool {} threw a runtime exception", poolName, t);
}
};
};
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {

View File

@@ -16,8 +16,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.SessionFactory;
import com.codahale.metrics.Meter;
@@ -152,7 +152,7 @@ public class FeedRefreshUpdater implements Managed {
}
}
if (config.getApplicationSettings().isPubsubhubbub()) {
if (config.getApplicationSettings().getPubsubhubbub()) {
handlePubSub(feed);
}
if (!ok) {
@@ -193,7 +193,7 @@ public class FeedRefreshUpdater implements Managed {
boolean inserted = new UnitOfWork<Boolean>(sessionFactory) {
@Override
protected Boolean runInSession() throws Exception {
return feedUpdateService.addEntry(feed, entry);
return feedUpdateService.addEntry(feed, entry, subscriptions);
}
}.run();
if (inserted) {

View File

@@ -11,8 +11,8 @@ import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedConfiguration;
@@ -90,7 +90,7 @@ public class FeedRefreshWorker implements Managed {
// stops here if NotModifiedException or any other exception is thrown
List<FeedEntry> entries = fetchedFeed.getEntries();
if (config.getApplicationSettings().isHeavyLoad()) {
if (config.getApplicationSettings().getHeavyLoad()) {
disabledUntil = FeedUtils.buildDisabledUntil(fetchedFeed.getFeed().getLastEntryDate(), fetchedFeed.getFeed()
.getAverageEntryInterval(), disabledUntil);
}
@@ -118,7 +118,7 @@ public class FeedRefreshWorker implements Managed {
} catch (NotModifiedException e) {
log.debug("Feed not modified : {} - {}", feed.getUrl(), e.getMessage());
if (config.getApplicationSettings().isHeavyLoad()) {
if (config.getApplicationSettings().getHeavyLoad()) {
disabledUntil = FeedUtils.buildDisabledUntil(feed.getLastEntryDate(), feed.getAverageEntryInterval(), disabledUntil);
}
feed.setErrorCount(0);

View File

@@ -13,9 +13,9 @@ import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@@ -25,14 +25,16 @@ import org.jsoup.nodes.Entities.EscapeMode;
import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Whitelist;
import org.jsoup.select.Elements;
import org.mozilla.universalchardet.UniversalDetector;
import org.w3c.css.sac.InputSource;
import org.w3c.dom.css.CSSStyleDeclaration;
import com.commafeed.backend.feed.FeedEntryKeyword.Mode;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.frontend.model.Entry;
import com.google.common.collect.Lists;
import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import com.steadystate.css.parser.CSSOMParser;
import edu.uci.ics.crawler4j.url.URLCanonicalizer;
@@ -113,15 +115,15 @@ public class FeedUtils {
* Detect encoding by analyzing characters in the array
*/
public static String detectEncoding(byte[] bytes) {
String DEFAULT_ENCODING = "UTF-8";
UniversalDetector detector = new UniversalDetector(null);
detector.handleData(bytes, 0, bytes.length);
detector.dataEnd();
String encoding = detector.getDetectedCharset();
detector.reset();
if (encoding == null) {
encoding = DEFAULT_ENCODING;
} else if (encoding.equalsIgnoreCase("ISO-8859-1")) {
String encoding = "UTF-8";
CharsetDetector detector = new CharsetDetector();
detector.setText(bytes);
CharsetMatch match = detector.detect();
if (match != null) {
encoding = match.getName();
}
if (encoding.equalsIgnoreCase("ISO-8859-1")) {
encoding = "windows-1252";
}
return encoding;
@@ -182,7 +184,7 @@ public class FeedUtils {
return null;
}
String pi = new String(ArrayUtils.subarray(bytes, 0, index + 1));
String pi = new String(ArrayUtils.subarray(bytes, 0, index + 1)).replace('\'', '"');
index = StringUtils.indexOf(pi, "encoding=\"");
if (index == -1) {
return null;
@@ -495,19 +497,20 @@ public class FeedUtils {
return rot13(new String(Base64.decodeBase64(code)));
}
public static void removeUnwantedFromSearch(List<Entry> entries, String keywords) {
if (StringUtils.isBlank(keywords)) {
return;
}
public static void removeUnwantedFromSearch(List<Entry> entries, List<FeedEntryKeyword> keywords) {
Iterator<Entry> it = entries.iterator();
while (it.hasNext()) {
Entry entry = it.next();
boolean keep = true;
for (String keyword : keywords.split(" ")) {
for (FeedEntryKeyword keyword : keywords) {
String title = Jsoup.parse(entry.getTitle()).text();
String content = Jsoup.parse(entry.getContent()).text();
if (!StringUtils.containsIgnoreCase(content, keyword) && !StringUtils.containsIgnoreCase(title, keyword)) {
boolean condition = !StringUtils.containsIgnoreCase(content, keyword.getKeyword())
&& !StringUtils.containsIgnoreCase(title, keyword.getKeyword());
if (keyword.getMode() == Mode.EXCLUDE) {
condition = !condition;
}
if (condition) {
keep = false;
break;
}

View File

@@ -40,4 +40,7 @@ public class FeedSubscription extends AbstractModel {
private Integer position;
@Column(length = 4096)
private String filter;
}

View File

@@ -15,7 +15,7 @@ import javax.persistence.TemporalType;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.annotations.Cascade;
import com.commafeed.backend.model.UserRole.Role;
@@ -78,7 +78,7 @@ public class User extends AbstractModel {
}
return false;
}
public boolean shouldRefreshFeedsAt(Date when) {
return (lastFullRefresh == null || lastFullRefreshMoreThan30MinutesBefore(when));
}

View File

@@ -13,6 +13,9 @@ import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
import com.google.common.base.Function;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.rometools.opml.feed.opml.Attribute;
import com.rometools.opml.feed.opml.Opml;
import com.rometools.opml.feed.opml.Outline;
@@ -21,6 +24,14 @@ import com.rometools.opml.feed.opml.Outline;
@Singleton
public class OPMLExporter {
private static Long ROOT_CATEGORY_ID = new Long(-1);
private static final Function<FeedSubscription, Long> SUBSCRIPTION_TO_CATEGORYID = new Function<FeedSubscription, Long>() {
@Override
public Long apply(FeedSubscription sub) {
return sub.getCategory() == null ? ROOT_CATEGORY_ID : sub.getCategory().getId();
}
};
private final FeedCategoryDAO feedCategoryDAO;
private final FeedSubscriptionDAO feedSubscriptionDAO;
@@ -31,7 +42,7 @@ public class OPMLExporter {
opml.setCreated(new Date());
List<FeedCategory> categories = feedCategoryDAO.findAll(user);
List<FeedSubscription> subscriptions = feedSubscriptionDAO.findAll(user);
Multimap<Long, FeedSubscription> subscriptions = Multimaps.index(feedSubscriptionDAO.findAll(user), SUBSCRIPTION_TO_CATEGORYID);
// export root categories
for (FeedCategory cat : categories) {
@@ -41,17 +52,15 @@ public class OPMLExporter {
}
// export root subscriptions
for (FeedSubscription sub : subscriptions) {
if (sub.getCategory() == null) {
opml.getOutlines().add(buildSubscriptionOutline(sub));
}
for (FeedSubscription sub : subscriptions.get(ROOT_CATEGORY_ID)) {
opml.getOutlines().add(buildSubscriptionOutline(sub));
}
return opml;
}
private Outline buildCategoryOutline(FeedCategory cat, List<FeedSubscription> subscriptions) {
private Outline buildCategoryOutline(FeedCategory cat, Multimap<Long, FeedSubscription> subscriptions) {
Outline outline = new Outline();
outline.setText(cat.getName());
outline.setTitle(cat.getName());
@@ -60,10 +69,8 @@ public class OPMLExporter {
outline.getChildren().add(buildCategoryOutline(child, subscriptions));
}
for (FeedSubscription sub : subscriptions) {
if (sub.getCategory() != null && sub.getCategory().getId().equals(cat.getId())) {
outline.getChildren().add(buildSubscriptionOutline(sub));
}
for (FeedSubscription sub : subscriptions.get(cat.getId())) {
outline.getChildren().add(buildSubscriptionOutline(sub));
}
return outline;
}

View File

@@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedCategoryDAO;

View File

@@ -19,8 +19,7 @@ public class OPML11Parser extends OPML10Parser {
public boolean isMyType(Document document) {
Element e = document.getRootElement();
if (e.getName().equals("opml") && (e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
&& (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.1"))) {
if (e.getName().equals("opml")) {
return true;
}

View File

@@ -1,9 +1,7 @@
package com.commafeed.backend.service;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -16,6 +14,7 @@ import org.hibernate.SessionFactory;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedEntryContentDAO;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedEntryDAO.FeedCapacity;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.model.Feed;
@@ -75,23 +74,37 @@ public class DatabaseCleaningService {
return total;
}
public long cleanEntriesOlderThan(long value, TimeUnit unit) {
final Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, -1 * (int) unit.toMinutes(value));
public long cleanEntriesForFeedsExceedingCapacity(final int maxFeedCapacity) {
long total = 0;
int deleted = 0;
do {
deleted = new UnitOfWork<Integer>(sessionFactory) {
while (true) {
List<FeedCapacity> feeds = new UnitOfWork<List<FeedCapacity>>(sessionFactory) {
@Override
protected Integer runInSession() throws Exception {
return feedEntryDAO.delete(cal.getTime(), BATCH_SIZE);
protected List<FeedCapacity> runInSession() throws Exception {
return feedEntryDAO.findFeedsExceedingCapacity(maxFeedCapacity, BATCH_SIZE);
}
}.run();
total += deleted;
log.info("removed {} entries", total);
} while (deleted != 0);
log.info("cleanup done: {} entries deleted", total);
if (feeds.isEmpty()) {
break;
}
for (final FeedCapacity feed : feeds) {
long remaining = feed.getCapacity() - maxFeedCapacity;
do {
final long rem = remaining;
int deleted = new UnitOfWork<Integer>(sessionFactory) {
@Override
protected Integer runInSession() throws Exception {
return feedEntryDAO.deleteOldEntries(feed.getId(), Math.min(BATCH_SIZE, rem));
};
}.run();
total += deleted;
remaining -= deleted;
log.info("removed {} entries for feeds exceeding capacity", total);
} while (remaining > 0);
}
}
log.info("cleanup done: {} entries for feeds exceeding capacity deleted", total);
return total;
}

View File

@@ -6,7 +6,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.backend.dao.FeedEntryContentDAO;
import com.commafeed.backend.feed.FeedUtils;

View File

@@ -0,0 +1,123 @@
package com.commafeed.backend.service;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import org.apache.commons.jexl2.JexlContext;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.JexlException;
import org.apache.commons.jexl2.JexlInfo;
import org.apache.commons.jexl2.MapContext;
import org.apache.commons.jexl2.Script;
import org.apache.commons.jexl2.introspection.JexlMethod;
import org.apache.commons.jexl2.introspection.JexlPropertyGet;
import org.apache.commons.jexl2.introspection.Uberspect;
import org.apache.commons.jexl2.introspection.UberspectImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.jsoup.Jsoup;
import com.commafeed.backend.model.FeedEntry;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class FeedEntryFilteringService {
private static final JexlEngine ENGINE = initEngine();
private static JexlEngine initEngine() {
// classloader that prevents object creation
ClassLoader cl = new ClassLoader() {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
return null;
}
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
return null;
}
};
// uberspect that prevents access to .class and .getClass()
Uberspect uberspect = new UberspectImpl(LogFactory.getLog(JexlEngine.class)) {
@Override
public JexlPropertyGet getPropertyGet(Object obj, Object identifier, JexlInfo info) {
if ("class".equals(identifier)) {
return null;
}
return super.getPropertyGet(obj, identifier, info);
}
@Override
public JexlMethod getMethod(Object obj, String method, Object[] args, JexlInfo info) {
if ("getClass".equals(method)) {
return null;
}
return super.getMethod(obj, method, args, info);
}
};
JexlEngine engine = new JexlEngine(uberspect, null, null, null);
engine.setStrict(true);
engine.setClassLoader(cl);
return engine;
}
private ExecutorService executor = Executors.newCachedThreadPool();
public boolean filterMatchesEntry(String filter, FeedEntry entry) throws FeedEntryFilterException {
if (StringUtils.isBlank(filter)) {
return true;
}
Script script = null;
try {
script = ENGINE.createScript(filter);
} catch (JexlException e) {
throw new FeedEntryFilterException("Exception while parsing expression " + filter, e);
}
JexlContext context = new MapContext();
context.set("title", entry.getContent().getTitle() == null ? "" : Jsoup.parse(entry.getContent().getTitle()).text().toLowerCase());
context.set("author", entry.getContent().getAuthor() == null ? "" : entry.getContent().getAuthor().toLowerCase());
context.set("content", entry.getContent().getContent() == null ? "" : Jsoup.parse(entry.getContent().getContent()).text()
.toLowerCase());
context.set("url", entry.getUrl() == null ? "" : entry.getUrl().toLowerCase());
Callable<Object> callable = script.callable(context);
Future<Object> future = executor.submit(callable);
Object result = null;
try {
result = future.get(500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new FeedEntryFilterException("interrupted while evaluating expression " + filter, e);
} catch (ExecutionException e) {
throw new FeedEntryFilterException("Exception while evaluating expression " + filter, e);
} catch (TimeoutException e) {
throw new FeedEntryFilterException("Took too long evaluating expression " + filter, e);
}
try {
return (boolean) result;
} catch (ClassCastException e) {
throw new FeedEntryFilterException(e.getMessage(), e);
}
}
@SuppressWarnings("serial")
public static class FeedEntryFilterException extends Exception {
public FeedEntryFilterException(String message, Throwable t) {
super(message, t);
}
}
}

View File

@@ -12,6 +12,7 @@ import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.feed.FeedEntryKeyword;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
@@ -65,9 +66,9 @@ public class FeedEntryService {
feedEntryStatusDAO.saveOrUpdate(status);
}
public void markSubscriptionEntries(User user, List<FeedSubscription> subscriptions, Date olderThan) {
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user, subscriptions, true, null, null, -1, -1, null, false,
false, null);
public void markSubscriptionEntries(User user, List<FeedSubscription> subscriptions, Date olderThan, List<FeedEntryKeyword> keywords) {
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user, subscriptions, true, keywords, null, -1, -1, null,
false, false, null);
markList(statuses, olderThan);
cache.invalidateUnreadCount(subscriptions.toArray(new FeedSubscription[0]));
cache.invalidateUserRootCategory(user);

View File

@@ -9,7 +9,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.cache.CacheService;

View File

@@ -1,30 +1,39 @@
package com.commafeed.backend.service;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryContent;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.service.FeedEntryFilteringService.FeedEntryFilterException;
@Slf4j
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class FeedUpdateService {
private final FeedEntryDAO feedEntryDAO;
private final FeedEntryStatusDAO feedEntryStatusDAO;
private final FeedEntryContentService feedEntryContentService;
private final FeedEntryFilteringService feedEntryFilteringService;
/**
* this is NOT thread-safe
*/
public boolean addEntry(Feed feed, FeedEntry entry) {
public boolean addEntry(Feed feed, FeedEntry entry, List<FeedSubscription> subscriptions) {
Long existing = feedEntryDAO.findExisting(entry.getGuid(), feed);
if (existing != null) {
@@ -36,8 +45,23 @@ public class FeedUpdateService {
entry.setContent(content);
entry.setInserted(new Date());
entry.setFeed(feed);
feedEntryDAO.saveOrUpdate(entry);
// if filter does not match the entry, mark it as read
for (FeedSubscription sub : subscriptions) {
boolean matches = true;
try {
matches = feedEntryFilteringService.filterMatchesEntry(sub.getFilter(), entry);
} catch (FeedEntryFilterException e) {
log.error("could not evaluate filter {}", sub.getFilter(), e);
}
if (!matches) {
FeedEntryStatus status = new FeedEntryStatus(sub.getUser(), sub, entry);
status.setRead(true);
feedEntryStatusDAO.saveOrUpdate(status);
}
}
return true;
}
}

View File

@@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.CommaFeedConfiguration.ApplicationSettings;
import com.commafeed.backend.model.User;
import com.google.common.base.Optional;
/**
* Mailing service
@@ -34,6 +35,7 @@ public class MailService {
final String username = settings.getSmtpUserName();
final String password = settings.getSmtpPassword();
final String fromAddress = Optional.fromNullable(settings.getSmtpFromAddress()).or(settings.getSmtpUserName());
String dest = user.getEmail();
@@ -51,7 +53,7 @@ public class MailService {
});
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(username, "CommaFeed"));
message.setFrom(new InternetAddress(fromAddress, "CommaFeed"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(dest));
message.setSubject("CommaFeed - " + subject);
message.setContent(content, "text/html; charset=utf-8");

View File

@@ -15,7 +15,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
// taken from http://www.javacodegeeks.com/2012/05/secure-password-storage-donts-dos-and.html
@SuppressWarnings("serial")

View File

@@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;

View File

@@ -26,6 +26,7 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.SessionFactoryImpl;
import com.commafeed.CommaFeedApplication;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.model.UserRole.Role;
@@ -38,6 +39,7 @@ public class StartupService implements Managed {
private final SessionFactory sessionFactory;
private final UserDAO userDAO;
private final UserService userService;
private final CommaFeedConfiguration config;
@Override
public void start() throws Exception {
@@ -95,7 +97,9 @@ public class StartupService implements Managed {
try {
userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER),
true);
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
if (config.getApplicationSettings().getCreateDemoAccount()) {
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}

View File

@@ -10,7 +10,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.FeedCategoryDAO;
@@ -33,7 +33,7 @@ public class UserService {
private final PasswordEncryptionService encryptionService;
private final CommaFeedConfiguration config;
private final PostLoginActivities postLoginActivities;
/**
@@ -56,7 +56,7 @@ public class UserService {
}
}
return Optional.absent();
}
}
/**
* try to log in with given api key
@@ -92,7 +92,7 @@ public class UserService {
Preconditions.checkNotNull(password);
if (!forceRegistration) {
Preconditions.checkState(config.getApplicationSettings().isAllowRegistrations(),
Preconditions.checkState(config.getApplicationSettings().getAllowRegistrations(),
"Registrations are closed on this CommaFeed instance");
Preconditions.checkNotNull(email);

View File

@@ -7,7 +7,7 @@ import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.time.DateUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.UserDAO;
@@ -17,11 +17,11 @@ import com.commafeed.backend.service.FeedSubscriptionService;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class PostLoginActivities {
private final UserDAO userDAO;
private final FeedSubscriptionService feedSubscriptionService;
private final CommaFeedConfiguration config;
public void executeFor(User user) {
Date lastLogin = user.getLastLogin();
Date now = new Date();
@@ -33,7 +33,7 @@ public class PostLoginActivities {
user.setLastLogin(now);
saveUser = true;
}
if (config.getApplicationSettings().isHeavyLoad() && user.shouldRefreshFeedsAt(now)) {
if (config.getApplicationSettings().getHeavyLoad() && user.shouldRefreshFeedsAt(now)) {
feedSubscriptionService.refreshAll(user);
user.setLastFullRefresh(now);
saveUser = true;

View File

@@ -0,0 +1,43 @@
package com.commafeed.backend.task;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.service.DatabaseCleaningService;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class OldEntriesCleanupTask extends ScheduledTask {
private final CommaFeedConfiguration config;
private final DatabaseCleaningService cleaner;
@Override
public void run() {
int maxFeedCapacity = config.getApplicationSettings().getMaxFeedCapacity();
if (maxFeedCapacity > 0) {
cleaner.cleanEntriesForFeedsExceedingCapacity(maxFeedCapacity);
}
}
@Override
public long getInitialDelay() {
return 5;
}
@Override
public long getPeriod() {
return 60;
}
@Override
public TimeUnit getTimeUnit() {
return TimeUnit.MINUTES;
}
}

View File

@@ -0,0 +1,38 @@
package com.commafeed.backend.task;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import com.commafeed.backend.service.DatabaseCleaningService;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class OrphanedContentsCleanupTask extends ScheduledTask {
private final DatabaseCleaningService cleaner;
@Override
public void run() {
cleaner.cleanContentsWithoutEntries();
}
@Override
public long getInitialDelay() {
return 20;
}
@Override
public long getPeriod() {
return 60;
}
@Override
public TimeUnit getTimeUnit() {
return TimeUnit.MINUTES;
}
}

View File

@@ -11,19 +11,18 @@ import com.commafeed.backend.service.DatabaseCleaningService;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class OrphansCleanupTask extends ScheduledTask {
public class OrphanedFeedsCleanupTask extends ScheduledTask {
private final DatabaseCleaningService cleaner;
@Override
public void run() {
cleaner.cleanFeedsWithoutSubscriptions();
cleaner.cleanContentsWithoutEntries();
}
@Override
public long getInitialDelay() {
return 5;
return 15;
}
@Override

View File

@@ -26,7 +26,8 @@ public abstract class ScheduledTask {
}
}
};
log.info("registering task {} for execution every {} {}, starting in {} {}", getClass().getSimpleName(), getPeriod(),
getTimeUnit(), getInitialDelay(), getTimeUnit());
executor.scheduleWithFixedDelay(runnable, getInitialDelay(), getPeriod(), getTimeUnit());
}
}

View File

@@ -0,0 +1,96 @@
package com.commafeed.frontend.auth;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.StringUtil;
import org.glassfish.jersey.server.internal.inject.AbstractContainerRequestValueFactory;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.service.UserService;
import com.commafeed.frontend.session.SessionHelper;
import com.google.common.base.Optional;
@RequiredArgsConstructor
public class SecurityCheckFactory extends AbstractContainerRequestValueFactory<User> {
private static final String PREFIX = "Basic";
@Context
HttpServletRequest request;
@Inject
UserService userService;
private final Role role;
private final boolean apiKeyAllowed;
@Override
public User provide() {
Optional<User> user = apiKeyLogin();
if (!user.isPresent()) {
user = basicAuthenticationLogin();
}
if (!user.isPresent()) {
user = cookieSessionLogin(new SessionHelper(request));
}
if (user.isPresent()) {
if (user.get().hasRole(role)) {
return user.get();
} else {
throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
.entity("You don't have the required role to access this resource.").type(MediaType.TEXT_PLAIN_TYPE).build());
}
} else {
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED)
.entity("Credentials are required to access this resource.").type(MediaType.TEXT_PLAIN_TYPE).build());
}
}
Optional<User> cookieSessionLogin(SessionHelper sessionHelper) {
Optional<User> loggedInUser = sessionHelper.getLoggedInUser();
if (loggedInUser.isPresent()) {
userService.performPostLoginActivities(loggedInUser.get());
}
return loggedInUser;
}
private Optional<User> basicAuthenticationLogin() {
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
if (header != null) {
int space = header.indexOf(' ');
if (space > 0) {
String method = header.substring(0, space);
if (PREFIX.equalsIgnoreCase(method)) {
String decoded = B64Code.decode(header.substring(space + 1), StringUtil.__ISO_8859_1);
int i = decoded.indexOf(':');
if (i > 0) {
String username = decoded.substring(0, i);
String password = decoded.substring(i + 1);
return userService.login(username, password);
}
}
}
}
return Optional.absent();
}
private Optional<User> apiKeyLogin() {
String apiKey = request.getParameter("apiKey");
if (apiKey != null && apiKeyAllowed) {
return userService.login(apiKey);
}
return Optional.absent();
}
}

View File

@@ -0,0 +1,64 @@
package com.commafeed.frontend.auth;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.api.InjectionResolver;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.api.TypeLiteral;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.internal.inject.AbstractValueFactoryProvider;
import org.glassfish.jersey.server.internal.inject.MultivaluedParameterExtractorProvider;
import org.glassfish.jersey.server.internal.inject.ParamInjectionResolver;
import org.glassfish.jersey.server.model.Parameter;
import org.glassfish.jersey.server.spi.internal.ValueFactoryProvider;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.UserService;
@Singleton
public class SecurityCheckFactoryProvider extends AbstractValueFactoryProvider {
@Inject
public SecurityCheckFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, final ServiceLocator injector) {
super(extractorProvider, injector, Parameter.Source.UNKNOWN);
}
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
final Class<?> classType = parameter.getRawType();
SecurityCheck securityCheck = parameter.getAnnotation(SecurityCheck.class);
if (securityCheck == null)
return null;
if (classType.isAssignableFrom(User.class)) {
return new SecurityCheckFactory(securityCheck.value(), securityCheck.apiKeyAllowed());
} else {
return null;
}
}
public static class SecurityCheckInjectionResolver extends ParamInjectionResolver<SecurityCheck> {
public SecurityCheckInjectionResolver() {
super(SecurityCheckFactoryProvider.class);
}
}
@RequiredArgsConstructor
public static class Binder extends AbstractBinder {
private final UserService userService;
@Override
protected void configure() {
bind(SecurityCheckFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(SecurityCheckInjectionResolver.class).to(new TypeLiteral<InjectionResolver<SecurityCheck>>() {
}).in(Singleton.class);
bind(userService).to(UserService.class);
}
}
}

View File

@@ -1,124 +0,0 @@
package com.commafeed.frontend.auth;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.StringUtil;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.service.UserService;
import com.commafeed.frontend.session.SessionHelper;
import com.google.common.base.Optional;
import com.sun.jersey.api.core.HttpContext;
import com.sun.jersey.api.model.Parameter;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider;
public class SecurityCheckProvider implements InjectableProvider<SecurityCheck, Parameter> {
public static class SecurityCheckUserServiceProvider extends SingletonTypeInjectableProvider<Context, UserService> {
public SecurityCheckUserServiceProvider(UserService userService) {
super(UserService.class, userService);
}
}
@RequiredArgsConstructor
static class SecurityCheckInjectable extends AbstractHttpContextInjectable<User> {
private static final String PREFIX = "Basic";
private final SessionHelper sessionHelper;
private final UserService userService;
private final Role role;
private final boolean apiKeyAllowed;
@Override
public User getValue(HttpContext c) {
Optional<User> user = apiKeyLogin(c);
if (!user.isPresent()) {
user = basicAuthenticationLogin(c);
}
if (!user.isPresent()) {
user = cookieSessionLogin();
}
if (user.isPresent()) {
if (user.get().hasRole(role)) {
return user.get();
} else {
throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
.entity("You don't have the required role to access this resource.").type(MediaType.TEXT_PLAIN_TYPE).build());
}
} else {
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED)
.entity("Credentials are required to access this resource.").type(MediaType.TEXT_PLAIN_TYPE).build());
}
}
Optional<User> cookieSessionLogin() {
Optional<User> loggedInUser = sessionHelper.getLoggedInUser();
if (loggedInUser.isPresent()) {
userService.performPostLoginActivities(loggedInUser.get());
}
return loggedInUser;
}
private Optional<User> basicAuthenticationLogin(HttpContext c) {
String header = c.getRequest().getHeaderValue(HttpHeaders.AUTHORIZATION);
if (header != null) {
int space = header.indexOf(' ');
if (space > 0) {
String method = header.substring(0, space);
if (PREFIX.equalsIgnoreCase(method)) {
String decoded = B64Code.decode(header.substring(space + 1), StringUtil.__ISO_8859_1);
int i = decoded.indexOf(':');
if (i > 0) {
String username = decoded.substring(0, i);
String password = decoded.substring(i + 1);
return userService.login(username, password);
}
}
}
}
return Optional.absent();
}
private Optional<User> apiKeyLogin(HttpContext c) {
String apiKey = c.getUriInfo().getQueryParameters().getFirst("apiKey");
if (apiKey != null && apiKeyAllowed) {
return userService.login(apiKey);
}
return Optional.absent();
}
}
private SessionHelper sessionHelper;
private UserService userService;
public SecurityCheckProvider(@Context HttpServletRequest req, @Context UserService userService) {
this.sessionHelper = new SessionHelper(req);
this.userService = userService;
}
@Override
public ComponentScope getScope() {
return ComponentScope.PerRequest;
}
@Override
public Injectable<?> getInjectable(ComponentContext ic, SecurityCheck sc, Parameter c) {
return new SecurityCheckInjectable(sessionHelper, userService, sc.value(), sc.apiKeyAllowed());
}
}

View File

@@ -16,6 +16,8 @@ import com.commafeed.backend.model.FeedSubscription;
import com.google.common.collect.Lists;
import com.rometools.rome.feed.synd.SyndContent;
import com.rometools.rome.feed.synd.SyndContentImpl;
import com.rometools.rome.feed.synd.SyndEnclosure;
import com.rometools.rome.feed.synd.SyndEnclosureImpl;
import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndEntryImpl;
import com.wordnik.swagger.annotations.ApiModel;
@@ -74,6 +76,14 @@ public class Entry implements Serializable {
SyndContentImpl content = new SyndContentImpl();
content.setValue(getContent());
entry.setContents(Arrays.<SyndContent> asList(content));
if (getEnclosureUrl() != null) {
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
enclosure.setType(getEnclosureType());
enclosure.setUrl(getEnclosureUrl());
entry.setEnclosures(Arrays.<SyndEnclosure> asList(enclosure));
}
entry.setLink(getUrl());
entry.setPublishedDate(getDate());
return entry;

View File

@@ -35,6 +35,7 @@ public class Subscription implements Serializable {
sub.setUnread(unreadCount.getUnreadCount());
sub.setNewestItemTime(unreadCount.getNewestItemTime());
sub.setCategoryId(category == null ? null : String.valueOf(category.getId()));
sub.setFilter(subscription.getFilter());
return sub;
}
@@ -77,4 +78,7 @@ public class Subscription implements Serializable {
@ApiModelProperty("date of the newest item")
private Date newestItemTime;
@ApiModelProperty(value = "JEXL string evaluated on new entries to mark them as read if they do not match")
private String filter;
}

View File

@@ -24,4 +24,7 @@ public class FeedModificationRequest implements Serializable {
@ApiModelProperty(value = "new display position, null if not changed")
private Integer position;
@ApiModelProperty(value = "JEXL string evaluated on new entries to mark them as read if they do not match")
private String filter;
}

View File

@@ -24,6 +24,9 @@ public class MarkRequest implements Serializable {
required = false)
private Long olderThan;
@ApiModelProperty(value = "only mark read if a feed has these keywords in the title or rss content", required = false)
private String keywords;
@ApiModelProperty(value = "if marking a category or 'all', exclude those subscriptions from the marking", required = false)
private List<Long> excludedSubscriptions;

View File

@@ -19,7 +19,7 @@ import javax.ws.rs.core.Response.Status;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedApplication;

View File

@@ -9,6 +9,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -27,14 +28,15 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.feed.FeedEntryKeyword;
import com.commafeed.backend.feed.FeedUtils;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedEntryStatus;
@@ -108,6 +110,7 @@ public class CategoryREST {
keywords = StringUtils.trimToNull(keywords);
Preconditions.checkArgument(keywords == null || StringUtils.length(keywords) >= 3);
List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);
limit = Math.min(limit, 1000);
limit = Math.max(0, limit);
@@ -134,13 +137,13 @@ public class CategoryREST {
entries.setName(Optional.fromNullable(tag).or("All"));
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
removeExcludedSubscriptions(subs, excludedIds);
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, keywords, newerThanDate, offset,
limit + 1, order, true, onlyIds, tag);
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,
offset, limit + 1, order, true, onlyIds, tag);
for (FeedEntryStatus status : list) {
entries.getEntries().add(
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
.isImageProxyEnabled()));
.getImageProxyEnabled()));
}
} else if (STARRED.equals(id)) {
@@ -149,7 +152,7 @@ public class CategoryREST {
for (FeedEntryStatus status : starred) {
entries.getEntries().add(
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
.isImageProxyEnabled()));
.getImageProxyEnabled()));
}
} else {
FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(id));
@@ -157,13 +160,13 @@ public class CategoryREST {
List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
removeExcludedSubscriptions(subs, excludedIds);
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, keywords, newerThanDate,
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,
offset, limit + 1, order, true, onlyIds, tag);
for (FeedEntryStatus status : list) {
entries.getEntries().add(
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
.isImageProxyEnabled()));
.getImageProxyEnabled()));
}
entries.setName(parent.getName());
} else {
@@ -179,7 +182,7 @@ public class CategoryREST {
entries.setTimestamp(System.currentTimeMillis());
entries.setIgnoredReadStatus(STARRED.equals(id) || keywords != null || tag != null);
FeedUtils.removeUnwantedFromSearch(entries.getEntries(), keywords);
FeedUtils.removeUnwantedFromSearch(entries.getEntries(), entryKeywords);
return Response.ok(entries).build();
}
@@ -243,11 +246,13 @@ public class CategoryREST {
Preconditions.checkNotNull(req.getId());
Date olderThan = req.getOlderThan() == null ? null : new Date(req.getOlderThan());
String keywords = req.getKeywords();
List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);
if (ALL.equals(req.getId())) {
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
feedEntryService.markSubscriptionEntries(user, subs, olderThan);
feedEntryService.markSubscriptionEntries(user, subs, olderThan, entryKeywords);
} else if (STARRED.equals(req.getId())) {
feedEntryService.markStarredEntries(user, olderThan);
} else {
@@ -255,7 +260,7 @@ public class CategoryREST {
List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
feedEntryService.markSubscriptionEntries(user, subs, olderThan);
feedEntryService.markSubscriptionEntries(user, subs, olderThan, entryKeywords);
}
return Response.ok().build();
}
@@ -359,7 +364,7 @@ public class CategoryREST {
int existingIndex = -1;
for (int i = 0; i < categories.size(); i++) {
if (ObjectUtils.equals(categories.get(i).getId(), category.getId())) {
if (Objects.equals(categories.get(i).getId(), category.getId())) {
existingIndex = i;
}
}
@@ -436,7 +441,7 @@ public class CategoryREST {
category.setExpanded(true);
for (FeedCategory c : categories) {
if ((id == null && c.getParent() == null) || (c.getParent() != null && ObjectUtils.equals(c.getParent().getId(), id))) {
if ((id == null && c.getParent() == null) || (c.getParent() != null && Objects.equals(c.getParent().getId(), id))) {
Category child = buildCategory(c.getId(), categories, subscriptions, unreadCount);
child.setId(String.valueOf(c.getId()));
child.setName(c.getName());
@@ -457,7 +462,7 @@ public class CategoryREST {
for (FeedSubscription subscription : subscriptions) {
if ((id == null && subscription.getCategory() == null)
|| (subscription.getCategory() != null && ObjectUtils.equals(subscription.getCategory().getId(), id))) {
|| (subscription.getCategory() != null && Objects.equals(subscription.getCategory().getId(), id))) {
UnreadCount uc = unreadCount.get(subscription.getId());
Subscription sub = Subscription.build(subscription, config.getApplicationSettings().getPublicUrl(), uc);
category.getFeeds().add(sub);

View File

@@ -11,6 +11,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -33,8 +34,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.media.multipart.FormDataParam;
import com.commafeed.CommaFeedApplication;
import com.commafeed.CommaFeedConfiguration;
@@ -42,12 +44,15 @@ import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.feed.FeedEntryKeyword;
import com.commafeed.backend.feed.FeedFetcher;
import com.commafeed.backend.feed.FeedQueues;
import com.commafeed.backend.feed.FeedUtils;
import com.commafeed.backend.feed.FetchedFeed;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryContent;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
@@ -55,6 +60,8 @@ import com.commafeed.backend.model.UserSettings.ReadingMode;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
import com.commafeed.backend.opml.OPMLExporter;
import com.commafeed.backend.opml.OPMLImporter;
import com.commafeed.backend.service.FeedEntryFilteringService;
import com.commafeed.backend.service.FeedEntryFilteringService.FeedEntryFilterException;
import com.commafeed.backend.service.FeedEntryService;
import com.commafeed.backend.service.FeedService;
import com.commafeed.backend.service.FeedSubscriptionService;
@@ -78,7 +85,6 @@ import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.feed.synd.SyndFeedImpl;
import com.rometools.rome.io.SyndFeedOutput;
import com.rometools.rome.io.WireFeedOutput;
import com.sun.jersey.multipart.FormDataParam;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@@ -92,6 +98,20 @@ import com.wordnik.swagger.annotations.ApiParam;
@Singleton
public class FeedREST {
private static final FeedEntry TEST_ENTRY = initTestEntry();
private static FeedEntry initTestEntry() {
FeedEntry entry = new FeedEntry();
entry.setUrl("https://github.com/Athou/commafeed");
FeedEntryContent content = new FeedEntryContent();
content.setAuthor("Athou");
content.setTitle("Merge pull request #662 from Athou/dw8");
content.setContent("Merge pull request #662 from Athou/dw8");
entry.setContent(content);
return entry;
}
private final FeedSubscriptionDAO feedSubscriptionDAO;
private final FeedCategoryDAO feedCategoryDAO;
private final FeedEntryStatusDAO feedEntryStatusDAO;
@@ -99,6 +119,7 @@ public class FeedREST {
private final FeedService feedService;
private final FeedEntryService feedEntryService;
private final FeedSubscriptionService feedSubscriptionService;
private final FeedEntryFilteringService feedEntryFilteringService;
private final FeedQueues queues;
private final OPMLImporter opmlImporter;
private final OPMLExporter opmlExporter;
@@ -126,6 +147,7 @@ public class FeedREST {
keywords = StringUtils.trimToNull(keywords);
Preconditions.checkArgument(keywords == null || StringUtils.length(keywords) >= 3);
List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);
limit = Math.min(limit, 1000);
limit = Math.max(0, limit);
@@ -145,13 +167,13 @@ public class FeedREST {
entries.setErrorCount(subscription.getFeed().getErrorCount());
entries.setFeedLink(subscription.getFeed().getLink());
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, Arrays.asList(subscription), unreadOnly, keywords,
newerThanDate, offset, limit + 1, order, true, onlyIds, null);
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, Arrays.asList(subscription), unreadOnly,
entryKeywords, newerThanDate, offset, limit + 1, order, true, onlyIds, null);
for (FeedEntryStatus status : list) {
entries.getEntries().add(
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
.isImageProxyEnabled()));
.getImageProxyEnabled()));
}
boolean hasMore = entries.getEntries().size() > limit;
@@ -165,7 +187,7 @@ public class FeedREST {
entries.setTimestamp(System.currentTimeMillis());
entries.setIgnoredReadStatus(keywords != null);
FeedUtils.removeUnwantedFromSearch(entries.getEntries(), keywords);
FeedUtils.removeUnwantedFromSearch(entries.getEntries(), entryKeywords);
return Response.ok(entries).build();
}
@@ -246,7 +268,7 @@ public class FeedREST {
info = fetchFeedInternal(req.getUrl());
} catch (Exception e) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(Throwables.getStackTraceAsString(Throwables.getRootCause(e)))
.build();
.type(MediaType.TEXT_PLAIN).build();
}
return Response.ok(info).build();
}
@@ -287,10 +309,12 @@ public class FeedREST {
Preconditions.checkNotNull(req.getId());
Date olderThan = req.getOlderThan() == null ? null : new Date(req.getOlderThan());
String keywords = req.getKeywords();
List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);
FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(req.getId()));
if (subscription != null) {
feedEntryService.markSubscriptionEntries(user, Arrays.asList(subscription), olderThan);
feedEntryService.markSubscriptionEntries(user, Arrays.asList(subscription), olderThan, entryKeywords);
}
return Response.ok().build();
}
@@ -416,7 +440,15 @@ public class FeedREST {
Preconditions.checkNotNull(req);
Preconditions.checkNotNull(req.getId());
try {
feedEntryFilteringService.filterMatchesEntry(req.getFilter(), TEST_ENTRY);
} catch (FeedEntryFilterException e) {
Throwable root = Throwables.getRootCause(e);
return Response.status(Status.BAD_REQUEST).entity(root.getMessage()).type(MediaType.TEXT_PLAIN).build();
}
FeedSubscription subscription = feedSubscriptionDAO.findById(user, req.getId());
subscription.setFilter(req.getFilter());
if (StringUtils.isNotBlank(req.getName())) {
subscription.setTitle(req.getName());
@@ -439,7 +471,7 @@ public class FeedREST {
int existingIndex = -1;
for (int i = 0; i < subs.size(); i++) {
if (ObjectUtils.equals(subs.get(i).getId(), subscription.getId())) {
if (Objects.equals(subs.get(i).getId(), subscription.getId())) {
existingIndex = i;
}
}

View File

@@ -23,8 +23,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedConfiguration;
@@ -57,7 +57,7 @@ public class PubSubHubbubCallbackREST {
public Response verify(@QueryParam("hub.mode") String mode, @QueryParam("hub.topic") String topic,
@QueryParam("hub.challenge") String challenge, @QueryParam("hub.lease_seconds") String leaseSeconds,
@QueryParam("hub.verify_token") String verifyToken) {
if (!config.getApplicationSettings().isPubsubhubbub()) {
if (!config.getApplicationSettings().getPubsubhubbub()) {
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
}
@@ -87,7 +87,7 @@ public class PubSubHubbubCallbackREST {
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
public Response callback() {
if (!config.getApplicationSettings().isPubsubhubbub()) {
if (!config.getApplicationSettings().getPubsubhubbub()) {
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
}

View File

@@ -15,7 +15,7 @@ import javax.ws.rs.core.Response.Status;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.HttpGetter;
@@ -47,7 +47,7 @@ public class ServerREST {
infos.setAnnouncement(config.getApplicationSettings().getAnnouncement());
infos.setVersion(config.getVersion());
infos.setGitCommit(config.getGitCommit());
infos.setAllowRegistrations(config.getApplicationSettings().isAllowRegistrations());
infos.setAllowRegistrations(config.getApplicationSettings().getAllowRegistrations());
infos.setGoogleAnalyticsCode(config.getApplicationSettings().getGoogleAnalyticsTrackingCode());
infos.setSmtpEnabled(StringUtils.isNotBlank(config.getApplicationSettings().getSmtpHost()));
return Response.ok(infos).build();
@@ -59,7 +59,7 @@ public class ServerREST {
@ApiOperation(value = "proxy image")
@Produces("image/png")
public Response get(@SecurityCheck User user, @QueryParam("u") String url) {
if (!config.getApplicationSettings().isImageProxyEnabled()) {
if (!config.getApplicationSettings().getImageProxyEnabled()) {
return Response.status(Status.FORBIDDEN).build();
}

View File

@@ -27,9 +27,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.http.client.utils.URIBuilder;
import com.commafeed.CommaFeedApplication;
@@ -249,7 +249,7 @@ public class UserREST {
sessionHelper.setLoggedInUser(user.get());
return Response.ok().build();
} else {
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").build();
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").type(MediaType.TEXT_PLAIN).build();
}
}
@@ -270,7 +270,8 @@ public class UserREST {
return Response.ok().build();
} catch (Exception e) {
log.error(e.getMessage(), e);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("could not send email: " + e.getMessage()).build();
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("could not send email: " + e.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}

View File

@@ -9,7 +9,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import com.commafeed.CommaFeedConfiguration;

View File

@@ -12,7 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
import com.commafeed.CommaFeedConfiguration;

View File

@@ -0,0 +1,17 @@
package com.commafeed.frontend.session;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import org.glassfish.jersey.server.internal.inject.AbstractContainerRequestValueFactory;
public class SessionHelperFactory extends AbstractContainerRequestValueFactory<SessionHelper> {
@Context
HttpServletRequest request;
@Override
public SessionHelper provide() {
return new SessionHelper(request);
}
}

View File

@@ -0,0 +1,56 @@
package com.commafeed.frontend.session;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.Context;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.api.InjectionResolver;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.api.TypeLiteral;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.internal.inject.AbstractValueFactoryProvider;
import org.glassfish.jersey.server.internal.inject.MultivaluedParameterExtractorProvider;
import org.glassfish.jersey.server.internal.inject.ParamInjectionResolver;
import org.glassfish.jersey.server.model.Parameter;
import org.glassfish.jersey.server.spi.internal.ValueFactoryProvider;
@Singleton
public class SessionHelperFactoryProvider extends AbstractValueFactoryProvider {
@Inject
public SessionHelperFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, final ServiceLocator injector) {
super(extractorProvider, injector, Parameter.Source.CONTEXT);
}
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
final Class<?> classType = parameter.getRawType();
Context context = parameter.getAnnotation(Context.class);
if (context == null)
return null;
if (classType.isAssignableFrom(SessionHelper.class)) {
return new SessionHelperFactory();
} else {
return null;
}
}
public static class SessionHelperInjectionResolver extends ParamInjectionResolver<Context> {
public SessionHelperInjectionResolver() {
super(SessionHelperFactoryProvider.class);
}
}
public static class Binder extends AbstractBinder {
@Override
protected void configure() {
bind(SessionHelperFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(SessionHelperInjectionResolver.class).to(new TypeLiteral<InjectionResolver<Context>>() {
}).in(Singleton.class);
}
}
}

View File

@@ -1,44 +0,0 @@
package com.commafeed.frontend.session;
import java.lang.reflect.Type;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
@Provider
public class SessionHelperProvider implements InjectableProvider<Context, Type> {
private final ThreadLocal<HttpServletRequest> request;
public SessionHelperProvider(@Context ThreadLocal<HttpServletRequest> request) {
this.request = request;
}
@Override
public ComponentScope getScope() {
return ComponentScope.PerRequest;
}
@Override
public Injectable<?> getInjectable(ComponentContext ic, final Context session, Type type) {
if (type.equals(SessionHelper.class)) {
return new Injectable<SessionHelper>() {
@Override
public SessionHelper getValue() {
final HttpServletRequest req = request.get();
if (req != null) {
return new SessionHelper(req);
}
return null;
}
};
}
return null;
}
}

View File

@@ -28,11 +28,11 @@ import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
/**
* See http://en.wikipedia.org/wiki/URL_normalization for a reference Note: some
* parts of the code are adapted from: http://stackoverflow.com/a/4057470/405418
* See http://en.wikipedia.org/wiki/URL_normalization for a reference Note: some parts of the code are adapted from:
* http://stackoverflow.com/a/4057470/405418
*
* @author Yasser Ganjisaffar <lastname at gmail dot com>
*/
@@ -46,7 +46,7 @@ public class URLCanonicalizer {
try {
URL canonicalURL = new URL(UrlResolver.resolveUrl(context == null ? "" : context, href));
String host = canonicalURL.getHost().toLowerCase();
if (StringUtils.isBlank(host)) {
// This is an invalid Url.
@@ -113,7 +113,7 @@ public class URLCanonicalizer {
URL result = new URL(protocol, host, port, pathAndQueryString);
return result.toExternalForm();
} catch (MalformedURLException ex) {
return null;
} catch (URISyntaxException ex) {
@@ -122,8 +122,7 @@ public class URLCanonicalizer {
}
/**
* Takes a query string, separates the constituent name-value pairs, and
* stores them in a SortedMap ordered by lexicographical order.
* Takes a query string, separates the constituent name-value pairs, and stores them in a SortedMap ordered by lexicographical order.
*
* @return Null if there is no query string.
*/
@@ -149,7 +148,7 @@ public class URLCanonicalizer {
params.put(tokens[0], "");
}
break;
case 2:
case 2:
params.put(tokens[0], tokens[1]);
break;
}
@@ -188,8 +187,7 @@ public class URLCanonicalizer {
}
/**
* Percent-encode values according the RFC 3986. The built-in Java
* URLEncoder does not encode according to the RFC, so we make the extra
* Percent-encode values according the RFC 3986. The built-in Java URLEncoder does not encode according to the RFC, so we make the extra
* replacements.
*
* @param string

View File

@@ -44,6 +44,8 @@
</changeSet>
<changeSet author="athou" id="force-feed-refresh">
<validCheckSum>7:9bf9357b47d8666dc7916f9a318138ad</validCheckSum>
<validCheckSum>7:625f651e4c4d8e0aa9576da291baf6a4</validCheckSum>
<update tableName="FEEDS">
<column name="lastUpdated" valueComputed="null"></column>
<column name="lastPublishedDate" valueComputed="null"></column>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet id="add-sub-filter" author="athou">
<addColumn tableName="FEEDSUBSCRIPTIONS">
<column name="filter" type="varchar(4096)" />
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@@ -9,5 +9,6 @@
<include file="changelogs/db.changelog-1.3.xml" />
<include file="changelogs/db.changelog-1.4.xml" />
<include file="changelogs/db.changelog-1.5.xml" />
<include file="changelogs/db.changelog-2.1.xml" />
</databaseChangeLog>

View File

@@ -2,7 +2,7 @@ package com.commafeed.backend;
import java.util.Comparator;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

View File

@@ -3,8 +3,6 @@ package com.commafeed.backend.feed;
import org.junit.Assert;
import org.junit.Test;
import com.commafeed.backend.feed.FeedUtils;
public class FeedUtilsTest {
@Test
@@ -55,4 +53,13 @@ public class FeedUtilsTest {
FeedUtils.toAbsoluteUrl("elisp_all_about_lines.html", "blog.xml", "http://ergoemacs.org/emacs/blog.xml"));
}
@Test
public void testExtractDeclaredEncoding() {
Assert.assertNull(FeedUtils.extractDeclaredEncoding("<?xml ?>".getBytes()));
Assert.assertNull(FeedUtils.extractDeclaredEncoding("<feed></feed>".getBytes()));
Assert.assertEquals("UTF-8", FeedUtils.extractDeclaredEncoding("<?xml encoding=\"UTF-8\" ?>".getBytes()));
Assert.assertEquals("UTF-8", FeedUtils.extractDeclaredEncoding("<?xml encoding='UTF-8' ?>".getBytes()));
Assert.assertEquals("UTF-8", FeedUtils.extractDeclaredEncoding("<?xml encoding='UTF-8'?>".getBytes()));
}
}

View File

@@ -0,0 +1,141 @@
package com.commafeed.backend.opml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
import com.rometools.opml.feed.opml.Opml;
import com.rometools.opml.feed.opml.Outline;
public class OPMLExporterTest {
@Mock
private FeedCategoryDAO feedCategoryDAO;
@Mock
private FeedSubscriptionDAO feedSubscriptionDAO;
private User user = new User();
private FeedCategory cat1 = new FeedCategory();
private FeedCategory cat2 = new FeedCategory();
private FeedSubscription rootFeed = newFeedSubscription("rootFeed", "rootFeed.com");
private FeedSubscription cat1Feed = newFeedSubscription("cat1Feed", "cat1Feed.com");
private FeedSubscription cat2Feed = newFeedSubscription("cat2Feed", "cat2Feed.com");
private List<FeedCategory> categories = new ArrayList<>();
private List<FeedSubscription> subscriptions = new ArrayList<>();
@Before
public void before_each_test() {
MockitoAnnotations.initMocks(this);
user.setName("John Doe");
cat1.setId(1l);
cat1.setName("cat1");
cat1.setParent(null);
cat1.setChildren(new HashSet<FeedCategory>());
cat1.setSubscriptions(new HashSet<FeedSubscription>());
cat2.setId(2l);
cat2.setName("cat2");
cat2.setParent(cat1);
cat2.setChildren(new HashSet<FeedCategory>());
cat2.setSubscriptions(new HashSet<FeedSubscription>());
cat1.getChildren().add(cat2);
rootFeed.setCategory(null);
cat1Feed.setCategory(cat1);
cat2Feed.setCategory(cat2);
cat1.getSubscriptions().add(cat1Feed);
cat2.getSubscriptions().add(cat2Feed);
categories.add(cat1);
categories.add(cat2);
subscriptions.add(rootFeed);
subscriptions.add(cat1Feed);
subscriptions.add(cat2Feed);
}
private Feed newFeed(String url) {
Feed feed = new Feed();
feed.setUrl(url);
return feed;
}
private FeedSubscription newFeedSubscription(String title, String url) {
FeedSubscription feedSubscription = new FeedSubscription();
feedSubscription.setTitle(title);
feedSubscription.setFeed(newFeed(url));
return feedSubscription;
}
@Test
public void generates_OPML_correctly() {
when(feedCategoryDAO.findAll(user)).thenReturn(categories);
when(feedSubscriptionDAO.findAll(user)).thenReturn(subscriptions);
Opml opml = new OPMLExporter(feedCategoryDAO, feedSubscriptionDAO).export(user);
List<Outline> rootOutlines = opml.getOutlines();
assertEquals(2, rootOutlines.size());
assertTrue(containsCategory(rootOutlines, "cat1"));
assertTrue(containsFeed(rootOutlines, "rootFeed", "rootFeed.com"));
Outline cat1Outline = getCategoryOutline(rootOutlines, "cat1");
List<Outline> cat1Children = cat1Outline.getChildren();
assertEquals(2, cat1Children.size());
assertTrue(containsCategory(cat1Children, "cat2"));
assertTrue(containsFeed(cat1Children, "cat1Feed", "cat1Feed.com"));
Outline cat2Outline = getCategoryOutline(cat1Children, "cat2");
List<Outline> cat2Children = cat2Outline.getChildren();
assertEquals(1, cat2Children.size());
assertTrue(containsFeed(cat2Children, "cat2Feed", "cat2Feed.com"));
}
private boolean containsCategory(List<Outline> outlines, String category) {
for (Outline o : outlines)
if (!"rss".equals(o.getType()))
if (category.equals(o.getTitle()))
return true;
return false;
}
private boolean containsFeed(List<Outline> outlines, String title, String url) {
for (Outline o : outlines)
if ("rss".equals(o.getType()))
if (title.equals(o.getTitle()) && o.getAttributeValue("xmlUrl").equals(url))
return true;
return false;
}
private Outline getCategoryOutline(List<Outline> outlines, String title) {
for (Outline o : outlines)
if (o.getTitle().equals(title))
return o;
return null;
}
}

View File

@@ -0,0 +1,52 @@
package com.commafeed.backend.opml;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mockito.Mockito;
import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.FeedSubscriptionService;
public class OPMLImporterTest {
@Test
public void testOpmlV10() throws IOException {
testOpmlVersion("/opml/opml_v1.0.xml");
}
@Test
public void testOpmlV11() throws IOException {
testOpmlVersion("/opml/opml_v1.1.xml");
}
@Test
public void testOpmlV20() throws IOException {
testOpmlVersion("/opml/opml_v2.0.xml");
}
@Test
public void testOpmlNoVersion() throws IOException {
testOpmlVersion("/opml/opml_noversion.xml");
}
private void testOpmlVersion(String fileName) throws IOException {
FeedCategoryDAO feedCategoryDAO = Mockito.mock(FeedCategoryDAO.class);
FeedSubscriptionService feedSubscriptionService = Mockito.mock(FeedSubscriptionService.class);
CacheService cacheService = Mockito.mock(CacheService.class);
User user = Mockito.mock(User.class);
String xml = IOUtils.toString(getClass().getResourceAsStream(fileName));
OPMLImporter importer = new OPMLImporter(feedCategoryDAO, feedSubscriptionService, cacheService);
importer.importOpml(user, xml);
Mockito.verify(feedSubscriptionService).subscribe(Mockito.eq(user), Mockito.anyString(), Mockito.anyString(),
Mockito.any(FeedCategory.class));
}
}

View File

@@ -0,0 +1,74 @@
package com.commafeed.backend.service;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryContent;
import com.commafeed.backend.service.FeedEntryFilteringService.FeedEntryFilterException;
public class FeedEntryFilteringServiceTest {
private FeedEntryFilteringService service;
private FeedEntry entry;
private FeedEntryContent content;
@Before
public void init() {
service = new FeedEntryFilteringService();
entry = new FeedEntry();
entry.setUrl("https://github.com/Athou/commafeed");
content = new FeedEntryContent();
content.setAuthor("Athou");
content.setTitle("Merge pull request #662 from Athou/dw8");
content.setContent("Merge pull request #662 from Athou/dw8");
entry.setContent(content);
}
@Test
public void emptyFilterMatchesFilter() throws FeedEntryFilterException {
Assert.assertTrue(service.filterMatchesEntry(null, entry));
}
@Test
public void blankFilterMatchesFilter() throws FeedEntryFilterException {
Assert.assertTrue(service.filterMatchesEntry("", entry));
}
@Test
public void simpleExpression() throws FeedEntryFilterException {
Assert.assertTrue(service.filterMatchesEntry("author eq 'athou'", entry));
}
@Test(expected = FeedEntryFilterException.class)
public void newIsDisabled() throws FeedEntryFilterException {
service.filterMatchesEntry("null eq new ('java.lang.String', 'athou')", entry);
}
@Test(expected = FeedEntryFilterException.class)
public void getClassMethodIsDisabled() throws FeedEntryFilterException {
service.filterMatchesEntry("null eq ''.getClass()", entry);
}
@Test
public void dotClassIsDisabled() throws FeedEntryFilterException {
Assert.assertTrue(service.filterMatchesEntry("null eq ''.class", entry));
}
@Test(expected = FeedEntryFilterException.class)
public void cannotLoopForever() throws FeedEntryFilterException {
service.filterMatchesEntry("while(true) {}", entry);
}
@Test
public void handlesNullCorrectly() throws FeedEntryFilterException {
entry.setContent(new FeedEntryContent());
service.filterMatchesEntry("author eq 'athou'", entry);
}
}

View File

@@ -9,11 +9,10 @@ import org.junit.Test;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.UserService;
import com.commafeed.backend.service.internal.PostLoginActivities;
import com.commafeed.frontend.auth.SecurityCheckProvider.SecurityCheckInjectable;
import com.commafeed.frontend.session.SessionHelper;
import com.google.common.base.Optional;
public class SecurityCheckInjectableTest {
public class SecurityCheckFactoryTest {
@Test
public void cookie_login_should_perform_post_login_activities_if_user_is_logged_in() {
@@ -26,8 +25,9 @@ public class SecurityCheckInjectableTest {
UserService service = new UserService(null, null, null, null, null, postLoginActivities);
SecurityCheckInjectable injectable = new SecurityCheckInjectable(sessionHelper, service, null, false);
injectable.cookieSessionLogin();
SecurityCheckFactory factory = new SecurityCheckFactory(null, false);
factory.userService = service;
factory.cookieSessionLogin(sessionHelper);
verify(postLoginActivities).executeFor(userInSession);
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<opml>
<head>
<title>subscriptions</title>
</head>
<body>
<outline text="out1" title="out1">
<outline type="rss" text="feed1" title="feed1" xmlUrl="http://www.feed.com/feed1.xml" htmlUrl="http://www.feed.com" />
</outline>
</body>
</opml>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>subscriptions</title>
</head>
<body>
<outline text="out1" title="out1">
<outline type="rss" text="feed1" title="feed1" xmlUrl="http://www.feed.com/feed1.xml" htmlUrl="http://www.feed.com" />
</outline>
</body>
</opml>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.1">
<head>
<title>subscriptions</title>
</head>
<body>
<outline text="out1" title="out1">
<outline type="rss" text="feed1" title="feed1" xmlUrl="http://www.feed.com/feed1.xml" htmlUrl="http://www.feed.com" />
</outline>
</body>
</opml>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>subscriptions</title>
</head>
<body>
<outline text="out1" title="out1">
<outline type="rss" text="feed1" title="feed1" xmlUrl="http://www.feed.com/feed1.xml" htmlUrl="http://www.feed.com" />
</outline>
</body>
</opml>