Sotaro KARASAWA 9 лет назад
Родитель
Сommit
0d8ec9394c

+ 0 - 1
lib/routes/attachment.js

@@ -145,7 +145,6 @@ module.exports = function(crowi, app) {
             page: page.toObject(),
             attachment: data.toObject(),
             url: fileUrl,
-            filename: fileUrl, // this is for inline-attachemnets plugin http://inlineattachment.readthedocs.io/en/latest/pages/configuration.html
             pageCreated: pageCreated,
           };
 

+ 7 - 0
resource/css/_attachments.scss

@@ -2,6 +2,13 @@
 .page-attachments {
   .attachment-in-use {
     margin: 0 0 0 4px;
+    padding: 1px 5px;
+  }
+
+  .attachment-filetype {
+    margin: 0 0 0 4px;
+    padding: 1px 5px;
+    font-weight: normal;
   }
 
   .attachment-delete {

+ 4 - 0
resource/js/components/PageAttachment/Attachment.js

@@ -33,6 +33,8 @@ export default class Attachment extends React.Component {
       fileInUse = <span className="attachment-in-use label label-info">In Use</span>;
     }
 
+    const fileType = <span className="attachment-filetype label label-default">{attachment.fileFormat}</span>;
+
     return (
       <li>
           <User user={attachment.creator} />
@@ -40,6 +42,8 @@ export default class Attachment extends React.Component {
 
           <a href={attachment.url}> {attachment.originalName}</a>
 
+          {fileType}
+
           {fileInUse}
 
           <a className="text-danger attachment-delete" onClick={this._onAttachmentDeleteClicked}><Icon name="trash-o" /></a>

+ 14 - 3
resource/js/crowi-form.js

@@ -425,15 +425,26 @@ $(function() {
         _csrf: csrfToken
       },
       progressText: '(Uploading file...)',
-      urlText: "![file]({filename})\n",
-      allowedTypes: '*'
+      jsonFieldName: 'url',
+    };
+
+    // if files upload is set
+    var config = crowi.getConfig();
+    if (config.upload.file) {
+      attachmentOption.allowedTypes = '*';
+    }
+
+    attachmentOption.remoteFilename = function(file) {
+      return file.name;
     };
 
     attachmentOption.onFileReceived = function(file) {
       // if not image
       if (!file.type.match(/^image\/.+$/)) {
         // modify urlText with 'a' tag
-        this.settings.urlText = `<a href="{filename}">${file.name}</a>\n`;
+        this.settings.urlText = `[${file.name}]({filename})\n`;
+      } else {
+        this.settings.urlText = `![${file.name}]({filename})\n`;
       }
     }
 

+ 1 - 1
resource/js/util/Crowi.js

@@ -43,7 +43,7 @@ export default class Crowi {
   }
 
   recoverData() {
-  const keys = [
+    const keys = [
       'userByName',
       'userById',
       'users',