Skip to content

Commit

Permalink
HTML 5 player video function
Browse files Browse the repository at this point in the history
fix #219
  • Loading branch information
gnujavasergio committed Jul 11, 2022
1 parent e2d8874 commit 6f5725a
Show file tree
Hide file tree
Showing 22 changed files with 508 additions and 468 deletions.
10 changes: 0 additions & 10 deletions src/main/java/com/openkm/bean/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class Document extends Node {
private LockInfo lockInfo;
private boolean signed;
private boolean convertibleToPdf;
private boolean convertibleToSwf;
private String cipherName;

public LockInfo getLockInfo() {
Expand Down Expand Up @@ -137,14 +136,6 @@ public void setConvertibleToPdf(boolean convertibleToPdf) {
this.convertibleToPdf = convertibleToPdf;
}

public boolean isConvertibleToSwf() {
return convertibleToSwf;
}

public void setConvertibleToSwf(boolean convertibleToSwf) {
this.convertibleToSwf = convertibleToSwf;
}

public void setCipherName(String cipherName) {
this.cipherName = cipherName;
}
Expand Down Expand Up @@ -182,7 +173,6 @@ public String toString() {
sb.append(", subscriptors=").append(subscriptors);
sb.append(", uuid=").append(uuid);
sb.append(", convertibleToPdf=").append(convertibleToPdf);
sb.append(", convertibleToSwf=").append(convertibleToSwf);
sb.append(", cipherName=").append(cipherName);
sb.append(", notes=").append(notes);
sb.append(", language=").append(language);
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/com/openkm/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public class Config {
public static String REPOSITORY_CACHE_DIRNAME = "cache";
public static String REPOSITORY_CACHE_DXF;
public static String REPOSITORY_CACHE_PDF;
public static String REPOSITORY_CACHE_SWF;

// Experimental features
public static final String PROPERTY_PLUGIN_DEBUG = "plugin.debug";
Expand Down Expand Up @@ -221,7 +220,6 @@ public class Config {
public static final String PROPERTY_SYSTEM_OPENOFFICE_PROGRAM = "system.openoffice.program";
public static final String PROPERTY_SYSTEM_OPENOFFICE_DICTIONARY = "system.openoffice.dictionary";
public static final String PROPERTY_SYSTEM_IMAGEMAGICK_CONVERT = "system.imagemagick.convert";
public static final String PROPERTY_SYSTEM_SWFTOOLS_PDF2SWF = "system.swftools.pdf2swf";
public static final String PROPERTY_SYSTEM_GHOSTSCRIPT = "system.ghostscript";
public static final String PROPERTY_SYSTEM_DWG2DXF = "system.dwg2dxf";
public static final String PROPERTY_SYSTEM_ANTIVIR = "system.antivir";
Expand Down Expand Up @@ -486,7 +484,6 @@ public class Config {
public static String SYSTEM_OPENOFFICE_PROGRAM = "";
public static String SYSTEM_OPENOFFICE_DICTIONARY = "";
public static String SYSTEM_IMAGEMAGICK_CONVERT = "";
public static String SYSTEM_SWFTOOLS_PDF2SWF = "";
public static String SYSTEM_GHOSTSCRIPT = "";
public static String SYSTEM_DWG2DXF = "";
public static String SYSTEM_ANTIVIR = "";
Expand Down Expand Up @@ -732,8 +729,6 @@ public static Properties load(ServletContext sc) {
values.put("repository.cache.dxf", REPOSITORY_CACHE_DXF);
REPOSITORY_CACHE_PDF = REPOSITORY_CACHE_HOME + File.separator + "pdf";
values.put("repository.cache.pdf", REPOSITORY_CACHE_PDF);
REPOSITORY_CACHE_SWF = REPOSITORY_CACHE_HOME + File.separator + "swf";
values.put("repository.cache.swf", REPOSITORY_CACHE_SWF);
values.put(PROPERTY_HIBERNATE_SEARCH_INDEX_HOME, HIBERNATE_SEARCH_INDEX_HOME);
values.put(PROPERTY_REPOSITORY_DATASTORE_BACKEND, REPOSITORY_DATASTORE_BACKEND);
values.put(PROPERTY_REPOSITORY_DATASTORE_HOME, REPOSITORY_DATASTORE_HOME);
Expand Down Expand Up @@ -967,8 +962,6 @@ public static void reload(ServletContext sc, Properties cfg) {
values.put(PROPERTY_SYSTEM_PDF_FORCE_OCR, Boolean.toString(SYSTEM_PDF_FORCE_OCR));
SYSTEM_IMAGEMAGICK_CONVERT = ConfigDAO.getString(PROPERTY_SYSTEM_IMAGEMAGICK_CONVERT, cfg.getProperty(PROPERTY_SYSTEM_IMAGEMAGICK_CONVERT, EnvironmentDetector.detectImagemagickConvert()));
values.put(PROPERTY_SYSTEM_IMAGEMAGICK_CONVERT, SYSTEM_IMAGEMAGICK_CONVERT);
SYSTEM_SWFTOOLS_PDF2SWF = ConfigDAO.getString(PROPERTY_SYSTEM_SWFTOOLS_PDF2SWF, cfg.getProperty(PROPERTY_SYSTEM_SWFTOOLS_PDF2SWF, EnvironmentDetector.detectSwftoolsPdf2Swf()));
values.put(PROPERTY_SYSTEM_SWFTOOLS_PDF2SWF, SYSTEM_SWFTOOLS_PDF2SWF);
SYSTEM_GHOSTSCRIPT = ConfigDAO.getString(PROPERTY_SYSTEM_GHOSTSCRIPT, cfg.getProperty(PROPERTY_SYSTEM_GHOSTSCRIPT, EnvironmentDetector.detectGhostscript()));
values.put(PROPERTY_SYSTEM_GHOSTSCRIPT, SYSTEM_GHOSTSCRIPT);
SYSTEM_DWG2DXF = ConfigDAO.getString(PROPERTY_SYSTEM_DWG2DXF, cfg.getProperty(PROPERTY_SYSTEM_DWG2DXF, ""));
Expand Down
36 changes: 28 additions & 8 deletions src/main/java/com/openkm/core/MimeTypeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class MimeTypeConfig {

// MIME types => NOTE Keep on sync with default.sql
public final static String MIME_UNDEFINED = "application/octet-stream";

// application
public final static String MIME_RTF = "application/rtf";
public final static String MIME_PDF = "application/pdf";
public final static String MIME_ZIP = "application/zip";
Expand All @@ -48,6 +50,8 @@ public class MimeTypeConfig {
public final static String MIME_OO_SPREADSHEET = "application/vnd.oasis.opendocument.spreadsheet";
public final static String MIME_OO_PRESENTATION = "application/vnd.oasis.opendocument.presentation";
public final static String MIME_SWF = "application/x-shockwave-flash";

// Image
public final static String MIME_DXF = "image/vnd.dxf";
public final static String MIME_DWG = "image/vnd.dwg";
public final static String MIME_TIFF = "image/tiff";
Expand All @@ -57,28 +61,44 @@ public class MimeTypeConfig {
public final static String MIME_BMP = "image/bmp";
public final static String MIME_PSD = "image/x-psd";
public final static String MIME_ICO = "image/x-ico";
public final static String MIME_PBM = "image/pbm";
public final static String MIME_SVG = "image/svg+xml";

// Video
public final static String MIME_MP3 = "audio/mpeg";
public final static String MIME_WAV = "audio/x-wav";
public final static String MIME_MP4 = "video/mp4";
public final static String MIME_MPEG = "video/mpeg";
public final static String MIME_FLV = "video/x-flv";
public final static String MIME_WMV = "video/x-ms-wmv";
public final static String MIME_AVI = "video/x-msvideo";

// Text
public final static String MIME_HTML = "text/html";
public final static String MIME_TEXT = "text/plain";
public final static String MIME_XML = "text/xml";
public final static String MIME_CSV = "text/csv";
public final static String MIME_CSS = "text/css";

// Language
public final static String MIME_SQL = "text/x-sql";
public final static String MIME_JAVA = "text/x-java";
public final static String MIME_JAR = "application/x-java-archive";
public final static String MIME_SH = "application/x-shellscript";
public final static String MIME_BSH = "application/x-bsh";
public final static String MIME_PHP = "application/x-php";
public final static String MIME_SCALA = "text/x-scala";
public final static String MIME_PYTHON = "text/x-python";
public final static String MIME_PERL = "application/x-perl";
public final static String MIME_JAVASCRIPT = "application/javascript";
public final static String MIME_GROOVY = "text/x-groovy";
public final static String MIME_DIFF = "text/x-diff";
public final static String MIME_PASCAL = "text/x-pascal";
public final static String MIME_CSS = "text/css";
public final static String MIME_CSHARP = "text/x-csharp";
public final static String MIME_CPP = "text/x-c++";
public final static String MIME_AS3 = "application/x-font-truetype";
public final static String MIME_APPLESCRIPT = "text/applescript";
public final static String MIME_SH = "application/x-shellscript";
public final static String MIME_BSH = "application/x-bsh";
public final static String MIME_PHP = "application/x-php";
public final static String MIME_PERL = "application/x-perl";
public final static String MIME_JAVASCRIPT = "application/javascript";
public final static String MIME_AS3 = "application/x-font-truetype";

// Mail
public final static String MIME_EML = "message/rfc822";

//public final static String MIME_VB = "";
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/openkm/dao/bean/AutomationRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class AutomationRule implements Serializable {
public static final String EVENT_TEXT_EXTRACTOR = "text_extractor";

public static final String EVENT_CONVERSION_PDF = "convert_pdf";
public static final String EVENT_CONVERSION_SWF = "convert_swf";

public static final String EVENT_PROPERTY_GROUP_ADD = "prop_group_add";
public static final String EVENT_PROPERTY_GROUP_SET = "prop_group_set";
Expand Down Expand Up @@ -81,13 +80,12 @@ public class AutomationRule implements Serializable {
put(AutomationRule.EVENT_TEXT_EXTRACTOR, "Text extraction");

put(AutomationRule.EVENT_CONVERSION_PDF, "Convert to PDF");
put(AutomationRule.EVENT_CONVERSION_SWF, "Convert to SWF");

put(AutomationRule.EVENT_USER_LOGIN, "User login");
put(AutomationRule.EVENT_USER_LOGOUT, "User logout");
}
};

@Id
@Column(name = "ARL_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class GWTConverterStatus implements IsSerializable {
public static final int STATUS_LOADING = 1;
public static final int STATUS_CONVERTING_TO_PDF = 2;
public static final int STATUS_CONVERTING_TO_PDF_FINISHED = 3;
public static final int STATUS_CONVERTING_TO_SWF = 4;
public static final int STATUS_CONVERTING_TO_SWF_FINISHED = 5;
public static final int STATUS_SENDING_FILE = 6;

private int status = STATUS_LOADING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public abstract class PreviewExtension extends Composite implements HasPreviewEx
public abstract void setVisible(boolean visible);

public abstract void resizeViewer(int width, int height);
}

public abstract boolean isPreviewAvailable(String mimeType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ public void onSuccess(GWTConverterStatus result) {
case GWTConverterStatus.STATUS_CONVERTING_TO_PDF_FINISHED:
Main.get().mainPanel.bottomPanel.setStatus(Main.i18n("status.converter.topdf.finished"));
break;
case GWTConverterStatus.STATUS_CONVERTING_TO_SWF:
Main.get().mainPanel.bottomPanel.setStatus(Main.i18n("status.converter.toswf"));
break;
case GWTConverterStatus.STATUS_CONVERTING_TO_SWF_FINISHED:
Main.get().mainPanel.bottomPanel.setStatus(Main.i18n("status.converter.toswf.finished"));
break;
case GWTConverterStatus.STATUS_SENDING_FILE:
Main.get().mainPanel.bottomPanel.setStatus(Main.i18n("status.converter.sending.file"));
break;
Expand Down Expand Up @@ -99,4 +93,4 @@ public void run() {

refreshStatus.schedule(REFRESH_STATUS_DELAY);
}
}
}
40 changes: 0 additions & 40 deletions src/main/java/com/openkm/frontend/client/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,46 +574,6 @@ public static native String getUserAgent() /*-{
}
}-*/;

public static native void createPDFViewerFlexPaper(String pdfUrl, String width, String height) /*-{
fpViewer = "../js/flexpaper/FlexPaperViewer.swf";
pdfUrl = encodeURIComponent(pdfUrl);
$wnd.swfobject.embedSWF(fpViewer, "pdfviewercontainer", width, height, "10.0.0", "playerProductInstall.swf",
{
SwfFile: pdfUrl,
Scale: 0.6,
ZoomTransition: "easeOut",
ZoomTime: 0.5,
ZoomInterval: 0.1,
FitPageOnLoad: false,
FitWidthOnLoad: true,
FullScreenAsMaxWindow: false,
ProgressiveLoading: true,
ViewModeToolsVisible: true,
ZoomToolsVisible: true,
FullScreenVisible: true,
NavToolsVisible: true,
CursorToolsVisible: true,
SearchToolsVisible: true,
localeChain: "en_US"
},
{
quality: "high",
bgcolor: "#ffffff",
allowscriptaccess: "sameDomain",
allowfullscreen: "true"
},
{
id: "FlexPaperViewer",
name: "FlexPaperViewer"
});
}-*/;

public static native void resizePDFViewerFlexPaper(String width, String height) /*-{
obj = $wnd.swfobject.getObjectById('FlexPaperViewer');
obj.width = width;
obj.height = height;
}-*/;

public static native void resizeEmbededPDF(String width, String height, String pdfId) /*-{
obj = $wnd.document.getElementById(pdfId);
// Take in consideration if object exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,26 @@ private void hideWidgetExtension() {
/**
* Sets the boolean value if previewing document is available
*
* @param previewAvailable Set preview availability status.
* @param doc Set preview availability status.
*/
public void setPreviewAvailable(boolean previewAvailable) {
this.previewAvailable = previewAvailable;
public void setPreviewAvailable(GWTDocument doc) {
if (doc.getMimeType().equals("video/x-flv") || doc.getMimeType().equals("video/mp4") || doc.getMimeType().equals("audio/mpeg")
|| doc.getMimeType().equals("audio/x-wav") || doc.getMimeType().equals("application/pdf")
|| doc.getMimeType().equals("application/postscript") || doc.getMimeType().equals("application/x-shockwave-flash")
|| isHTMLPreviewAvailable(doc.getMimeType())
|| isSyntaxHighlighterPreviewAvailable(doc.getMimeType())
|| doc.isConvertibleToSwf() || doc.isConvertibleToPdf()) {
previewAvailable = true;
} else {
boolean found = false;
for (PreviewExtension preview : widgetPreviewExtensionList) {
if (preview.isPreviewAvailable(doc.getMimeType())) {
found = true;
break;
}
}
previewAvailable = found;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,7 @@ public void setProperties(GWTDocument doc) {
}

if (previewVisible) {
preview.setPreviewAvailable(doc.isConvertibleToSwf()
|| doc.getMimeType().equals("application/x-shockwave-flash")
|| HTMLPreview.isPreviewAvailable(doc.getMimeType())
|| SyntaxHighlighterPreview.isPreviewAvailable(doc.getMimeType()));
preview.setPreviewAvailable(doc);
}

if (!propertyGroup.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ public class CommonGeneralModule {
public static void cleanPreviewCache(String uuid) {
new File(Config.REPOSITORY_CACHE_DXF + File.separator + uuid + ".dxf").delete();
new File(Config.REPOSITORY_CACHE_PDF + File.separator + uuid + ".pdf").delete();
new File(Config.REPOSITORY_CACHE_SWF + File.separator + uuid + ".swf").delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ public static Document getProperties(String user, NodeDocument nDocument) throws
// Document conversion capabilities
DocConverter convert = DocConverter.getInstance();
doc.setConvertibleToPdf(convert.convertibleToPdf(doc.getMimeType()));
doc.setConvertibleToSwf(convert.convertibleToSwf(doc.getMimeType()));

// Get user subscription & keywords
doc.setSubscriptors(nDocument.getSubscriptors());
Expand Down
77 changes: 0 additions & 77 deletions src/main/java/com/openkm/servlet/HtmlPreviewServlet.java

This file was deleted.

Loading

0 comments on commit 6f5725a

Please sign in to comment.