tags.append(tag);
}
+ // TODO: i18n
metaDesc.put("Author", meta.getAuthor());
metaDesc.put("Publication date", formatDate(meta.getDate()));
metaDesc.put("Published on", meta.getPublisher());
metaDesc.put("URL", meta.getUrl());
+ String count = "";
+ if (meta.getWords() > 0) {
+ count = StringUtils.formatNumber(meta.getWords());
+ }
if (meta.isImageDocument()) {
- metaDesc.put("Number of images",
- StringUtils.formatNumber(meta.getWords()));
+ metaDesc.put("Number of images", count);
} else {
- metaDesc.put("Number of words",
- StringUtils.formatNumber(meta.getWords()));
+ metaDesc.put("Number of words", count);
}
metaDesc.put("Source", meta.getSource());
metaDesc.put("Subject", meta.getSubject());
static private String formatDate(String date) {
long ms = 0;
- try {
- ms = StringUtils.toTime(date);
- } catch (ParseException e) {
- }
-
- if (ms <= 0) {
- SimpleDateFormat sdf = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ssSSS");
+ if (date != null && !date.isEmpty()) {
try {
- ms = sdf.parse(date).getTime();
+ ms = StringUtils.toTime(date);
} catch (ParseException e) {
}
+
+ if (ms <= 0) {
+ SimpleDateFormat sdf = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ssSSS");
+ try {
+ ms = sdf.parse(date).getTime();
+ } catch (ParseException e) {
+ }
+ }
+
+ if (ms > 0) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ return sdf.format(new Date(ms));
+ }
}
- if (ms > 0) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- return sdf.format(new Date(ms));
+ if (date == null) {
+ date = "";
}
// :(
package be.nikiroo.fanfix.reader.ui;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.ui.GuiReaderBook.BookActionListener;
import be.nikiroo.fanfix.searchable.BasicSearchable;
import be.nikiroo.fanfix.searchable.SearchableTag;
import be.nikiroo.fanfix.supported.SupportType;
private boolean seeWordcount;
private GuiReaderGroup books;
- public GuiReaderSearch(GuiReader reader) {
+ public GuiReaderSearch(final GuiReader reader) {
// TODO: i18n
super("Browse stories");
setLayout(new BorderLayout());
add(top, BorderLayout.NORTH);
books = new GuiReaderGroup(reader, null, null);
+ books.setActionListener(new BookActionListener() {
+ @Override
+ public void select(GuiReaderBook book) {
+ }
+
+ @Override
+ public void popupRequested(GuiReaderBook book, Component target,
+ int x, int y) {
+ }
+
+ @Override
+ public void action(GuiReaderBook book) {
+ new GuiReaderSearchAction(reader.getLibrary(), book.getInfo())
+ .setVisible(true);
+ }
+ });
JScrollPane scroll = new JScrollPane(books);
scroll.getVerticalScrollBar().setUnitIncrement(16);
add(scroll, BorderLayout.CENTER);
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.StringIdGui;
import be.nikiroo.fanfix.data.Chapter;
+import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ui.ImageUtilsAwt;
* Create a new viewer.
*
* @param story
- * the {@link Story} to work on.
+ * the {@link Story} to work on
*/
public GuiReaderViewerPanel(Story story) {
+ this(story.getMeta(), story.getMeta().isImageDocument());
+ }
+
+ /**
+ * Create a new viewer.
+ *
+ * @param meta
+ * the {@link MetaData} of the story to show
+ * @param isImageDocument
+ * TRUE if it is an image document, FALSE if not
+ */
+ public GuiReaderViewerPanel(MetaData meta, boolean isImageDocument) {
super(new BorderLayout());
- this.imageDocument = story.getMeta().isImageDocument();
+ this.imageDocument = isImageDocument;
this.text = new JEditorPane("text/html", "");
text.setEditable(false);
main.invalidate();
}
- setChapter(story.getMeta().getResume());
+ setChapter(meta.getResume());
}
/**
MetaData meta = new MetaData();
meta.setImageDocument(false);
meta.setSource(getType().getSourceName());
+ meta.setPublisher(getType().getSourceName());
+ meta.setType(getType().toString());
// Title, URL, Cover
Element stitle = story.getElementsByClass("stitle").first();
if (stitle != null) {
meta.setTitle(stitle.text());
meta.setUrl(stitle.absUrl("href"));
+ meta.setUuid(meta.getUrl());
Element cover = stitle.getElementsByTag("img").first();
if (cover != null) {
// note: see data-original if needed?
if (infos != null) {
String[] tab = infos.outerHtml().split("<br>");
+ meta.setLang("fr");
+ meta.setSource(getType().getSourceName());
+ meta.setPublisher(getType().getSourceName());
+ meta.setType(getType().toString());
+ meta.setSubject("manga");
+ meta.setImageDocument(true);
meta.setTitle(getVal(tab, 0));
meta.setAuthor(getVal(tab, 1));
meta.setTags(Arrays.asList(getVal(tab, 2).split(" ")));
if (projectId >= 0) {
meta.setUrl("http://mangas-lecture-en-ligne.fr/index_lel.php?page=presentationProjet&idProjet="
+ projectId);
+ meta.setUuid(meta.getUrl());
metas.add(meta);
}
}