Skip to content

Commit

Permalink
Add icon to mimetype mindmap
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTom committed Mar 10, 2020
1 parent 6020921 commit ad802f6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 19 deletions.
6 changes: 6 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
#body-public .full-height {
height: 100%;
}

.ie #body-public .full-height {
display: block;
}

#mmframe {
padding-top: inherit;
}

.icon-mindmap
{
background-image: url("../img/mindmap.svg") !important;
}
1 change: 1 addition & 0 deletions img/mindmap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 28 additions & 1 deletion js/mindmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var FilesMindMap = {
_fileList: null,
init: function() {
this.registerFileActions();
this.hackFileIcon();
},

showMessage: function(msg, delay, t) {
Expand Down Expand Up @@ -197,6 +198,32 @@ var FilesMindMap = {
});
},

hackFileIcon: function() {
var changeMindmapIcons = function() {
$("#filestable")
.find("tr[data-type=file]")
.each(function () {
if (($(this).attr("data-mime") == "application/km")
&& ($(this).find("div.thumbnail").length > 0)) {
if ($(this).find("div.thumbnail").hasClass("icon-mindmap") == false) {
$(this).find("div.thumbnail").addClass("icon icon-mindmap");
}
}
});
}

if ($('#filesApp').val()) {
$('#app-content-files')
.add('#app-content-extstoragemounts')
.on('changeDirectory', function (e) {
changeMindmapIcons();
})
.on('fileActionsReady', function (e) {
changeMindmapIcons();
});
}
},

_onEditorTrigger: function(fileName, context) {
this._currentContext = context;
this._file.name = fileName;
Expand Down Expand Up @@ -233,7 +260,7 @@ FilesMindMap.NewFileMenuPlugin = {
id: 'mindmapfile',
displayName: t('files_mindmap', 'New mind map file'),
templateName: t('files_mindmap', 'New mind map.km'),
iconClass: 'icon-link',
iconClass: 'icon-mindmap',
fileType: 'application/km',
actionHandler: function(name) {
var dir = fileList.getCurrentDirectory();
Expand Down
2 changes: 1 addition & 1 deletion js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ redirectIfNotDisplayedInFrame();
if (self.getAutoSaveStatus()) {
self.save();
}
}, 5000);
}, 10000);
},
getAutoSaveStatus: function() {
var status = $('#autosave-checkbox').is(':checked');
Expand Down
20 changes: 11 additions & 9 deletions lib/Migration/InstallStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ public function getName() {
* @param IOutput $output
*/
public function run(IOutput $output) {
$configDir = \OC::$configDir;
$mimetypealiasesFile = $configDir . 'mimetypealiases.json';
$mimetypemappingFile = $configDir . 'mimetypemapping.json';

$this->appendToFile($mimetypealiasesFile, ['application/km' => 'mindmap']);
$this->appendToFile($mimetypemappingFile, ['km' => ['application/km']]);
$this->logger->info("Add .km to mimetype list.", ["app" => "files_mindmap"]);

$this->updateJS->run(new StringInput(''), new NullOutput());
$configDir = \OC::$configDir;
$mimetypealiasesFile = $configDir . 'mimetypealiases.json';
$mimetypemappingFile = $configDir . 'mimetypemapping.json';

$this->appendToFile($mimetypealiasesFile, ['application/km' => 'mindmap']);
$this->appendToFile($mimetypemappingFile, ['km' => ['application/km']]);
$this->logger->info("Add .km to mimetype list.", ["app" => "files_mindmap"]);
$this->updateJS->run(new StringInput(''), new NullOutput());

$this->logger->info("Copy mindmap icon to core/img directory.", ["app" => "files_mindmap"]);
copy(__DIR__ . '/../../img/mindmap.svg', \OC::$SERVERROOT . '/core/img/filetypes/mindmap.svg');

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Mar 11, 2020

Please instead send a PR to the server so we can add the image.

This comment has been minimized.

Copy link
@ACTom

ACTom Mar 13, 2020

Author Owner

@nickvergessen Thank you for your suggestion.
nextcloud/server#19942

}

private function appendToFile(string $filename, array $data) {
Expand Down
16 changes: 9 additions & 7 deletions lib/Migration/UninstallStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ public function getName() {
* @param IOutput $output
*/
public function run(IOutput $output) {
$configDir = \OC::$configDir;
$mimetypealiasesFile = $configDir . 'mimetypealiases.json';
$mimetypemappingFile = $configDir . 'mimetypemapping.json';
$configDir = \OC::$configDir;
$mimetypealiasesFile = $configDir . 'mimetypealiases.json';
$mimetypemappingFile = $configDir . 'mimetypemapping.json';

$this->removeFromFile($mimetypealiasesFile, ['application/km' => 'mindmap']);
$this->removeFromFile($mimetypemappingFile, ['km' => 'application/km']);
$this->logger->info("Remove .km from mimetype list.", ["app" => "files_mindmap"]);
$this->removeFromFile($mimetypealiasesFile, ['application/km' => 'mindmap']);
$this->removeFromFile($mimetypemappingFile, ['km' => 'application/km']);
$this->logger->info("Remove .km from mimetype list.", ["app" => "files_mindmap"]);
$this->updateJS->run(new StringInput(''), new NullOutput());

$this->updateJS->run(new StringInput(''), new NullOutput());
$this->logger->info("Remove mindmap icon from core/img directory.", ["app" => "files_mindmap"]);
unlink(\OC::$SERVERROOT . '/core/img/filetypes/mindmap.svg');
}

private function removeFromFile(string $filename, array $data) {
Expand Down
2 changes: 1 addition & 1 deletion templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
position: absolute;
right: 280px;
z-index: 100000;
width: 60px;
width: 100px;
}
#autosave-checkbox {
bottom: 3px;
Expand Down

0 comments on commit ad802f6

Please sign in to comment.