forked from Archives/Athou_commafeed
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) {
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.commafeed.frontend.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.commafeed.backend.model.UserSettings.IconDisplayMode;
|
||||
import com.commafeed.backend.model.UserSettings.ReadingMode;
|
||||
import com.commafeed.backend.model.UserSettings.ReadingOrder;
|
||||
import com.commafeed.backend.model.UserSettings.ScrollMode;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
@@ -20,13 +25,13 @@ public class Settings implements Serializable {
|
||||
description = "user reads all entries or unread entries only",
|
||||
allowableValues = "all,unread",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private String readingMode;
|
||||
private ReadingMode readingMode;
|
||||
|
||||
@Schema(
|
||||
description = "user reads entries in ascending or descending order",
|
||||
allowableValues = "asc,desc",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private String readingOrder;
|
||||
private ReadingOrder readingOrder;
|
||||
|
||||
@Schema(description = "user wants category and feeds with no unread entries shown", requiredMode = RequiredMode.REQUIRED)
|
||||
private boolean showRead;
|
||||
@@ -47,7 +52,7 @@ public class Settings implements Serializable {
|
||||
description = "whether to scroll to the selected entry",
|
||||
allowableValues = "always,never,if_needed",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private String scrollMode;
|
||||
private ScrollMode scrollMode;
|
||||
|
||||
@Schema(description = "number of entries to keep above the selected entry when scrolling", requiredMode = RequiredMode.REQUIRED)
|
||||
private int entriesToKeepOnTopWhenScrolling;
|
||||
@@ -56,13 +61,13 @@ public class Settings implements Serializable {
|
||||
description = "whether to show the star icon in the header of entries",
|
||||
allowableValues = "always,never,on_desktop,on_mobile",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private String starIconDisplayMode;
|
||||
private IconDisplayMode starIconDisplayMode;
|
||||
|
||||
@Schema(
|
||||
description = "whether to show the external link icon in the header of entries",
|
||||
allowableValues = "always,never,on_desktop,on_mobile",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private String externalLinkIconDisplayMode;
|
||||
private IconDisplayMode externalLinkIconDisplayMode;
|
||||
|
||||
@Schema(description = "ask for confirmation when marking all entries as read", requiredMode = RequiredMode.REQUIRED)
|
||||
private boolean markAllAsReadConfirmation;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class CategoryREST {
|
||||
Entries entries = new Entries();
|
||||
entries.setOffset(offset);
|
||||
entries.setLimit(limit);
|
||||
boolean unreadOnly = readType == ReadingMode.unread;
|
||||
boolean unreadOnly = readType == ReadingMode.UNREAD;
|
||||
if (StringUtils.isBlank(id)) {
|
||||
id = ALL;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class FeedREST {
|
||||
entries.setOffset(offset);
|
||||
entries.setLimit(limit);
|
||||
|
||||
boolean unreadOnly = readType == ReadingMode.unread;
|
||||
boolean unreadOnly = readType == ReadingMode.UNREAD;
|
||||
|
||||
Instant newerThanDate = newerThan == null ? null : Instant.ofEpochMilli(newerThan);
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ public class UserREST {
|
||||
User user = authenticationContext.getCurrentUser();
|
||||
UserSettings settings = userSettingsDAO.findByUser(user);
|
||||
if (settings != null) {
|
||||
s.setReadingMode(settings.getReadingMode().name());
|
||||
s.setReadingOrder(settings.getReadingOrder().name());
|
||||
s.setReadingMode(settings.getReadingMode());
|
||||
s.setReadingOrder(settings.getReadingOrder());
|
||||
s.setShowRead(settings.isShowRead());
|
||||
|
||||
s.getSharingSettings().setEmail(settings.isEmail());
|
||||
@@ -116,10 +116,10 @@ public class UserREST {
|
||||
s.setCustomJs(settings.getCustomJs());
|
||||
s.setLanguage(settings.getLanguage());
|
||||
s.setScrollSpeed(settings.getScrollSpeed());
|
||||
s.setScrollMode(settings.getScrollMode().name());
|
||||
s.setScrollMode(settings.getScrollMode());
|
||||
s.setEntriesToKeepOnTopWhenScrolling(settings.getEntriesToKeepOnTopWhenScrolling());
|
||||
s.setStarIconDisplayMode(settings.getStarIconDisplayMode().name());
|
||||
s.setExternalLinkIconDisplayMode(settings.getExternalLinkIconDisplayMode().name());
|
||||
s.setStarIconDisplayMode(settings.getStarIconDisplayMode());
|
||||
s.setExternalLinkIconDisplayMode(settings.getExternalLinkIconDisplayMode());
|
||||
s.setMarkAllAsReadConfirmation(settings.isMarkAllAsReadConfirmation());
|
||||
s.setMarkAllAsReadNavigateToNextUnread(settings.isMarkAllAsReadNavigateToNextUnread());
|
||||
s.setCustomContextMenu(settings.isCustomContextMenu());
|
||||
@@ -128,8 +128,8 @@ public class UserREST {
|
||||
s.setUnreadCountFavicon(settings.isUnreadCountFavicon());
|
||||
s.setPrimaryColor(settings.getPrimaryColor());
|
||||
} else {
|
||||
s.setReadingMode(ReadingMode.unread.name());
|
||||
s.setReadingOrder(ReadingOrder.desc.name());
|
||||
s.setReadingMode(ReadingMode.UNREAD);
|
||||
s.setReadingOrder(ReadingOrder.DESC);
|
||||
s.setShowRead(true);
|
||||
|
||||
s.getSharingSettings().setEmail(true);
|
||||
@@ -144,10 +144,10 @@ public class UserREST {
|
||||
s.setScrollMarks(true);
|
||||
s.setLanguage("en");
|
||||
s.setScrollSpeed(400);
|
||||
s.setScrollMode(ScrollMode.if_needed.name());
|
||||
s.setScrollMode(ScrollMode.IF_NEEDED);
|
||||
s.setEntriesToKeepOnTopWhenScrolling(1);
|
||||
s.setStarIconDisplayMode(IconDisplayMode.on_desktop.name());
|
||||
s.setExternalLinkIconDisplayMode(IconDisplayMode.on_desktop.name());
|
||||
s.setStarIconDisplayMode(IconDisplayMode.ON_DESKTOP);
|
||||
s.setExternalLinkIconDisplayMode(IconDisplayMode.ON_DESKTOP);
|
||||
s.setMarkAllAsReadConfirmation(true);
|
||||
s.setMarkAllAsReadNavigateToNextUnread(false);
|
||||
s.setCustomContextMenu(true);
|
||||
@@ -171,18 +171,18 @@ public class UserREST {
|
||||
s = new UserSettings();
|
||||
s.setUser(user);
|
||||
}
|
||||
s.setReadingMode(ReadingMode.valueOf(settings.getReadingMode()));
|
||||
s.setReadingOrder(ReadingOrder.valueOf(settings.getReadingOrder()));
|
||||
s.setReadingMode(settings.getReadingMode());
|
||||
s.setReadingOrder(settings.getReadingOrder());
|
||||
s.setShowRead(settings.isShowRead());
|
||||
s.setScrollMarks(settings.isScrollMarks());
|
||||
s.setCustomCss(settings.getCustomCss());
|
||||
s.setCustomJs(CommaFeedConstants.USERNAME_DEMO.equals(user.getName()) ? "" : settings.getCustomJs());
|
||||
s.setLanguage(settings.getLanguage());
|
||||
s.setScrollSpeed(settings.getScrollSpeed());
|
||||
s.setScrollMode(ScrollMode.valueOf(settings.getScrollMode()));
|
||||
s.setScrollMode(settings.getScrollMode());
|
||||
s.setEntriesToKeepOnTopWhenScrolling(settings.getEntriesToKeepOnTopWhenScrolling());
|
||||
s.setStarIconDisplayMode(IconDisplayMode.valueOf(settings.getStarIconDisplayMode()));
|
||||
s.setExternalLinkIconDisplayMode(IconDisplayMode.valueOf(settings.getExternalLinkIconDisplayMode()));
|
||||
s.setStarIconDisplayMode(settings.getStarIconDisplayMode());
|
||||
s.setExternalLinkIconDisplayMode(settings.getExternalLinkIconDisplayMode());
|
||||
s.setMarkAllAsReadConfirmation(settings.isMarkAllAsReadConfirmation());
|
||||
s.setMarkAllAsReadNavigateToNextUnread(settings.isMarkAllAsReadNavigateToNextUnread());
|
||||
s.setCustomContextMenu(settings.isCustomContextMenu());
|
||||
|
||||
@@ -251,12 +251,12 @@ public class FeverREST {
|
||||
|
||||
private List<Long> buildUnreadItemIds(User user, List<FeedSubscription> subscriptions) {
|
||||
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user, subscriptions, true, null, null, 0,
|
||||
UNREAD_ITEM_IDS_BATCH_SIZE, ReadingOrder.desc, false, null, null, null);
|
||||
UNREAD_ITEM_IDS_BATCH_SIZE, ReadingOrder.DESC, false, null, null, null);
|
||||
return statuses.stream().map(s -> s.getEntry().getId()).toList();
|
||||
}
|
||||
|
||||
private List<Long> buildSavedItemIds(User user) {
|
||||
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findStarred(user, null, 0, SAVED_ITEM_IDS_BATCH_SIZE, ReadingOrder.desc, false);
|
||||
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findStarred(user, null, 0, SAVED_ITEM_IDS_BATCH_SIZE, ReadingOrder.DESC, false);
|
||||
return statuses.stream().map(s -> s.getEntry().getId()).toList();
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class FeverREST {
|
||||
|
||||
private List<FeverItem> buildItems(User user, List<FeedSubscription> subscriptions, Long sinceId, Long maxId) {
|
||||
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(user, subscriptions, false, null, null, 0, ITEMS_BATCH_SIZE,
|
||||
ReadingOrder.desc, false, null, sinceId, maxId);
|
||||
ReadingOrder.DESC, false, null, sinceId, maxId);
|
||||
return statuses.stream().map(this::mapStatus).toList();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,4 +10,18 @@
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="uppercase-enum-values" author="athou">
|
||||
<update tableName="USERSETTINGS">
|
||||
<column name="readingOrder" valueComputed="upper(readingOrder)" />
|
||||
<column name="readingMode" valueComputed="upper(readingMode)" />
|
||||
<column name="scrollMode" valueComputed="upper(scrollMode)" />
|
||||
<column name="starIconDisplayMode" valueComputed="upper(starIconDisplayMode)" />
|
||||
<column name="externalLinkIconDisplayMode" valueComputed="upper(externalLinkIconDisplayMode)" />
|
||||
</update>
|
||||
<update tableName="FEEDENTRYCONTENTS">
|
||||
<column name="direction" valueComputed="upper(direction)" />
|
||||
</update>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
Reference in New Issue
Block a user