mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-23 12:35:07 +00:00
remove more warnings
This commit is contained in:
@@ -89,7 +89,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
||||
query.where(STATUS.entryInserted.gt(newerThan));
|
||||
}
|
||||
|
||||
if (order == ReadingOrder.asc) {
|
||||
if (order == ReadingOrder.ASC) {
|
||||
query.orderBy(STATUS.entryPublished.asc(), STATUS.id.asc());
|
||||
} else {
|
||||
query.orderBy(STATUS.entryPublished.desc(), STATUS.id.desc());
|
||||
@@ -162,7 +162,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
||||
}
|
||||
|
||||
if (order != null) {
|
||||
if (order == ReadingOrder.asc) {
|
||||
if (order == ReadingOrder.ASC) {
|
||||
query.orderBy(ENTRY.published.asc(), ENTRY.id.asc());
|
||||
} else {
|
||||
query.orderBy(ENTRY.published.desc(), ENTRY.id.desc());
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.commafeed.backend.feed;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -130,12 +128,7 @@ public class FeedUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new URL(new URL(baseUrl), relativeUrl).toString();
|
||||
} catch (MalformedURLException e) {
|
||||
log.debug("could not parse url : {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
return URI.create(baseUrl).resolve(relativeUrl).toString();
|
||||
}
|
||||
|
||||
public static String getFaviconUrl(FeedSubscription subscription) {
|
||||
@@ -195,26 +188,24 @@ public class FeedUtils {
|
||||
}
|
||||
|
||||
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;
|
||||
if (keywords.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
entries.removeIf(e -> {
|
||||
String title = e.getTitle() == null ? null : Jsoup.parse(e.getTitle()).text();
|
||||
String content = e.getContent() == null ? null : Jsoup.parse(e.getContent()).text();
|
||||
for (FeedEntryKeyword keyword : keywords) {
|
||||
String title = entry.getTitle() == null ? null : Jsoup.parse(entry.getTitle()).text();
|
||||
String content = entry.getContent() == null ? null : Jsoup.parse(entry.getContent()).text();
|
||||
boolean condition = !StringUtils.containsIgnoreCase(content, keyword.getKeyword())
|
||||
&& !StringUtils.containsIgnoreCase(title, keyword.getKeyword());
|
||||
if (keyword.getMode() == Mode.EXCLUDE) {
|
||||
condition = !condition;
|
||||
}
|
||||
if (condition) {
|
||||
keep = false;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!keep) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
|
||||
import com.commafeed.backend.feed.FeedUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -27,7 +28,14 @@ import lombok.Setter;
|
||||
public class FeedEntryContent extends AbstractModel {
|
||||
|
||||
public enum Direction {
|
||||
ltr, rtl, unknown
|
||||
@JsonProperty("ltr")
|
||||
LTR,
|
||||
|
||||
@JsonProperty("rtl")
|
||||
RTL,
|
||||
|
||||
@JsonProperty("unknown")
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
@Column(length = 2048)
|
||||
@@ -69,7 +77,7 @@ public class FeedEntryContent extends AbstractModel {
|
||||
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Direction direction = Direction.unknown;
|
||||
private Direction direction = Direction.UNKNOWN;
|
||||
|
||||
@OneToMany(mappedBy = "content")
|
||||
private Set<FeedEntry> entries;
|
||||
@@ -93,9 +101,9 @@ public class FeedEntryContent extends AbstractModel {
|
||||
}
|
||||
|
||||
public boolean isRTL() {
|
||||
if (direction == Direction.rtl) {
|
||||
if (direction == Direction.RTL) {
|
||||
return true;
|
||||
} else if (direction == Direction.ltr) {
|
||||
} else if (direction == Direction.LTR) {
|
||||
return false;
|
||||
} else {
|
||||
// detect on the fly for content that was inserted before the direction field was added
|
||||
|
||||
@@ -14,6 +14,8 @@ import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -25,23 +27,54 @@ import lombok.Setter;
|
||||
public class UserSettings extends AbstractModel {
|
||||
|
||||
public enum ReadingMode {
|
||||
all, unread
|
||||
@JsonProperty("all")
|
||||
ALL,
|
||||
|
||||
@JsonProperty("unread")
|
||||
UNREAD;
|
||||
|
||||
// method called for query parameters
|
||||
public static ReadingMode fromString(final String s) {
|
||||
return ReadingMode.valueOf(s.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
public enum ReadingOrder {
|
||||
asc, desc
|
||||
}
|
||||
@JsonProperty("asc")
|
||||
ASC,
|
||||
|
||||
public enum ViewMode {
|
||||
title, cozy, detailed, expanded
|
||||
@JsonProperty("desc")
|
||||
DESC;
|
||||
|
||||
// method called for query parameters
|
||||
public static ReadingOrder fromString(final String s) {
|
||||
return ReadingOrder.valueOf(s.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
public enum ScrollMode {
|
||||
always, never, if_needed
|
||||
@JsonProperty("always")
|
||||
ALWAYS,
|
||||
|
||||
@JsonProperty("never")
|
||||
NEVER,
|
||||
|
||||
@JsonProperty("if_needed")
|
||||
IF_NEEDED
|
||||
}
|
||||
|
||||
public enum IconDisplayMode {
|
||||
always, never, on_desktop, on_mobile
|
||||
@JsonProperty("always")
|
||||
ALWAYS,
|
||||
|
||||
@JsonProperty("never")
|
||||
NEVER,
|
||||
|
||||
@JsonProperty("on_desktop")
|
||||
ON_DESKTOP,
|
||||
|
||||
@JsonProperty("on_mobile")
|
||||
ON_MOBILE
|
||||
}
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FeedEntryContentService {
|
||||
entryContent.setAuthor(FeedUtils.truncate(cleaningService.clean(content.author(), baseUrl, true), 128));
|
||||
entryContent.setCategories(FeedUtils.truncate(content.categories(), 4096));
|
||||
entryContent.setDirection(
|
||||
FeedUtils.isRTL(content.title(), content.content()) ? FeedEntryContent.Direction.rtl : FeedEntryContent.Direction.ltr);
|
||||
FeedUtils.isRTL(content.title(), content.content()) ? FeedEntryContent.Direction.RTL : FeedEntryContent.Direction.LTR);
|
||||
|
||||
Enclosure enclosure = content.enclosure();
|
||||
if (enclosure != null) {
|
||||
|
||||
Reference in New Issue
Block a user