forked from Archives/Athou_commafeed
experimental rtl support (#209)
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -250,6 +250,11 @@
|
||||
<artifactId>juniversalchardet</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-servlet</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.google.api.client.util.Lists;
|
||||
import com.google.gwt.i18n.client.HasDirection.Direction;
|
||||
import com.google.gwt.i18n.shared.BidiUtils;
|
||||
|
||||
public class FeedUtils {
|
||||
|
||||
@@ -120,6 +122,12 @@ public class FeedUtils {
|
||||
return found;
|
||||
}
|
||||
|
||||
public static boolean isRTL(FeedEntry entry) {
|
||||
String content = entry.getContent().getContent();
|
||||
Direction direction = BidiUtils.get().estimateDirection(content, true);
|
||||
return direction == Direction.RTL;
|
||||
}
|
||||
|
||||
public static String trimInvalidXmlCharacters(String xml) {
|
||||
if (StringUtils.isBlank(xml)) {
|
||||
return null;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Entry implements Serializable {
|
||||
entry.setGuid(feedEntry.getGuid());
|
||||
entry.setTitle(feedEntry.getContent().getTitle());
|
||||
entry.setContent(feedEntry.getContent().getContent());
|
||||
entry.setRtl(FeedUtils.isRTL(feedEntry));
|
||||
entry.setAuthor(feedEntry.getAuthor());
|
||||
entry.setEnclosureUrl(status.getEntry().getContent().getEnclosureUrl());
|
||||
entry.setEnclosureType(status.getEntry().getContent()
|
||||
@@ -77,6 +78,9 @@ public class Entry implements Serializable {
|
||||
@ApiProperty("entry content")
|
||||
private String content;
|
||||
|
||||
@ApiProperty("wether entry content and title are rtl")
|
||||
private boolean rtl;
|
||||
|
||||
@ApiProperty("entry author")
|
||||
private String author;
|
||||
|
||||
@@ -241,4 +245,12 @@ public class Entry implements Serializable {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public boolean isRtl() {
|
||||
return rtl;
|
||||
}
|
||||
|
||||
public void setRtl(boolean rtl) {
|
||||
this.rtl = rtl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rtl {
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
.bs-fb ul {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
{{entry.feedName}}
|
||||
</span>
|
||||
<span class="entry-date visible-desktop">{{entry.date | entryDate}}</span>
|
||||
<span class="entry-name" ng-class="{unread: entry.read == false, shrink: true}" ng-bind-html-unsafe="entry.title"></span>
|
||||
<span class="entry-name" ng-class="{unread: entry.read == false, shrink: true, rtl: entry.rtl}" ng-bind-html-unsafe="entry.title"></span>
|
||||
|
||||
</a>
|
||||
<div class="entry-body" ui-if="settingsService.settings.viewMode == 'expanded' || (isOpen && current == entry)" ng-mouseup="bodyClicked(entry, $event)">
|
||||
<div class="entry-body" ui-if="settingsService.settings.viewMode == 'expanded' || (isOpen && current == entry)" ng-mouseup="bodyClicked(entry, $event)"
|
||||
ng-class="{rtl: entry.rtl}">
|
||||
<div class="entry-header">
|
||||
<h4 class="entry-title">
|
||||
<a href="{{entry.url}}" target="_blank" ng-bind-html-unsafe="entry.title"></a>
|
||||
|
||||
Reference in New Issue
Block a user