Skip to content

Commit

Permalink
add mediamanager root folder to config
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmaneuver committed Feb 13, 2014
1 parent b91c282 commit 1a65f45
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
3 changes: 2 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"i18n" => "en",
"docs_root" => $docsroot,
"mediamanager_root" => "userfiles",

"database" => [ "server" => "mongolite://".(__DIR__.'/storage/data'), "options" => ["db" => "cockpitdb"] ],

Expand All @@ -38,4 +39,4 @@
"encryption"=> "" // '', ssl' or 'tls'
]
*/
];
];
3 changes: 2 additions & 1 deletion modules/core/Cockpit/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
App.storage = Storage.select("cockpit", "local");
App.memory = Storage.select("cockpit", "memory");
App.i18n = window.i18n;
App.config = {};

global.App = App;

Expand All @@ -123,4 +124,4 @@
$doc.trigger("app-init");
});

})(this, jQuery, jQuery(window), jQuery(document));
})(this, jQuery, jQuery(window), jQuery(document));
6 changes: 5 additions & 1 deletion modules/core/Cockpit/views/layouts/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
@trigger('app.layout.header')
{{ $app->assets(["assets:angular/cockpit.js"], $app['cockpit/version']) }}
<script>
App.config = {{ json_encode($app["app.config"]) }};
</script>
</head>
<body>
Expand Down Expand Up @@ -86,4 +90,4 @@
@trigger("app.layout.footer")
</body>
</html>
</html>
30 changes: 17 additions & 13 deletions modules/core/Mediamanager/assets/js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function($){

var Editor = {

init: function($scope) {

if (this.element) {
Expand Down Expand Up @@ -45,7 +45,7 @@
// key mappings

this.code.addKeyMap({
'Ctrl-S': function(){ Editor.save(); },
'Ctrl-S': function(){ Editor.save(); },
'Cmd-S': function(){ Editor.save(); },
'Esc': function(){ Editor.close(); }
});
Expand All @@ -64,7 +64,7 @@
},

save: function(){

if(!this.file) {
return;
}
Expand All @@ -78,7 +78,7 @@
},

show: function(file, content){

var ext = file.name.split('.').pop().toLowerCase(),
mode = "text";

Expand Down Expand Up @@ -107,13 +107,13 @@
// autoload modes
if(mode!='text') {
App.assets.require(['/assets/vendor/codemirror/mode/%N/%N.js'.replace(/%N/g, mode)], function(){

switch(mode) {
case "php":
Editor.code.setOption("mode", "application/x-httpd-php");
break;
default:
Editor.code.setOption("mode", mode);
Editor.code.setOption("mode", mode);
}
});
}
Expand Down Expand Up @@ -142,7 +142,7 @@

App.module.controller("mediamanager", function($scope, $rootScope, $http){

var currentpath = location.hash ? location.hash.replace("#", ''):"/",
var currentpath = location.hash ? location.hash.replace("#", ''):App.config.mediamanager_root,
apiurl = App.route('/mediamanager/api'),

imgpreview = new $.UIkit.modal.Modal("#mm-image-preview");
Expand Down Expand Up @@ -238,12 +238,12 @@
imgpreview.show();
break;
case "text":

requestapi({"cmd":"readfile", "path": file.path}, function(content){
Editor.show(file, content);
}, "text");


break;
default:
App.notify("Sorry, this file type is not supported.");
Expand All @@ -268,7 +268,7 @@
};

$scope.addBookmark = function(item) {

var bookmark = {"name": item.name, "path": item.path},
cat = item.is_dir ? "folders":"files";

Expand Down Expand Up @@ -296,6 +296,8 @@

function loadPath(path) {

path = path === 'root' ? App.config.mediamanager_root : path;

requestapi({"cmd":"ls", "path": path}, function(data){

currentpath = path;
Expand All @@ -308,8 +310,10 @@
crumbs = [];

for(var i=0;i<parts.length;i++){
tmppath.push(parts[i]);
crumbs.push({'name':parts[i],'path':tmppath.join("/")});
if (parts[i] != App.config.mediamanager_root) {
tmppath.push(parts[i]);
crumbs.push({'name':parts[i],'path':tmppath.join("/")});
}
}

$scope.breadcrumbs = crumbs;
Expand Down Expand Up @@ -378,4 +382,4 @@

});

})(jQuery);
})(jQuery);
6 changes: 3 additions & 3 deletions modules/core/Mediamanager/assets/pathpicker.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$.UIkit.modalbox.close();
});

this.loadPath('/');
this.loadPath(App.config.mediamanager_root);


App.assets.require(['assets/vendor/ajaxupload.js'], function(){
Expand Down Expand Up @@ -108,7 +108,7 @@
var parts = path.split('/'),
tmppath = [];

$this.caption.append('<span data-path="/"><strong>site:</strong></span>');
$this.caption.append('<span data-path="'+App.config.mediamanager_root+'"><strong>site:</strong></span>');

for(var i=0;i<parts.length;i++){

Expand Down Expand Up @@ -266,4 +266,4 @@
.media-path-picker .media-select[disabled] { opacity:0; } \
</style>');

})(App.module, jQuery);
})(App.module, jQuery);
5 changes: 2 additions & 3 deletions modules/core/Mediamanager/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

{{ $app->assets(['assets:angular/directives/mediapreview.js'], $app['cockpit/version']) }}


<div class="app-wrapper" data-ng-controller="mediamanager" ng-cloak>

<div class="uk-navbar">
Expand Down Expand Up @@ -58,7 +57,7 @@
<div class="uk-panel app-panel-box docked">
<ul class="uk-breadcrumb">
<li ng-click="updatepath('/')"><a href="#/" title="Change dir to root"><i class="uk-icon-home"></i></a></li>
<li ng-click="updatepath('root')"><a href="#/" title="Change dir to root"><i class="uk-icon-home"></i></a></li>
<li ng-repeat="crumb in breadcrumbs"><a href="#@@ crumb.path @@" ng-click="updatepath(crumb.path)" title="Change dir to @@ crumb.name @@">@@ crumb.name @@</a></li>
</ul>
</div>
Expand Down Expand Up @@ -343,4 +342,4 @@
#mm-editor a { cursor: pointer; }
</style>
</style>

0 comments on commit 1a65f45

Please sign in to comment.