' +
@@ -52,7 +52,7 @@ Vue.component('component-image', {
}
},
mounted: function(){
- this.imgpreview = this.value;
+ this.imgpreview = myaxios.defaults.baseURL + '/' + this.value;
},
methods: {
update: function(value)
@@ -138,4 +138,503 @@ Vue.component('component-image', {
}
}
},
-})
\ No newline at end of file
+})
+
+const medialib = Vue.component('medialib', {
+ props: ['parentcomponent'],
+ template: '
',
+ data: function(){
+ return {
+ imagedata: false,
+ showimages: true,
+ imagedetaildata: false,
+ showimagedetails: false,
+ filedata: false,
+ showfiles: false,
+ filedetaildata: false,
+ showfiledetails: false,
+ detailindex: false,
+ load: false,
+ baseurl: myaxios.defaults.baseURL,
+ adminurl: false,
+ search: '',
+ errors: false,
+ }
+ },
+ mounted: function(){
+
+ if(this.parentcomponent == 'files')
+ {
+ this.showFiles();
+ }
+
+ this.errors = false;
+ var self = this;
+
+ myaxios.get('/api/v1/medialib/images',{
+ params: {
+ 'url': document.getElementById("path").value,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ self.imagedata = response.data.images;
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ self.errors = error.response.data.errors;
+ }
+ });
+ },
+ computed: {
+ filteredImages() {
+
+ var searchimages = this.search;
+ var filteredImages = {};
+ var images = this.imagedata;
+ if(images)
+ {
+ Object.keys(images).forEach(function(key) {
+ var searchindex = key + ' ' + images[key].name;
+ if(searchindex.toLowerCase().indexOf(searchimages.toLowerCase()) !== -1)
+ {
+ filteredImages[key] = images[key];
+ }
+ });
+ }
+ return filteredImages;
+ },
+ filteredFiles() {
+
+ var searchfiles = this.search;
+ var filteredFiles = {};
+ var files = this.filedata;
+ if(files)
+ {
+ Object.keys(files).forEach(function(key) {
+ var searchindex = key + ' ' + files[key].name;
+ if(searchindex.toLowerCase().indexOf(searchfiles.toLowerCase()) !== -1)
+ {
+ filteredFiles[key] = files[key];
+ }
+ });
+ }
+ return filteredFiles;
+ }
+ },
+ methods: {
+ isImagesActive: function()
+ {
+ if(this.showimages)
+ {
+ return 'bg-tm-green white';
+ }
+ return 'bg-light-gray black';
+ },
+ isFilesActive: function()
+ {
+ if(this.showfiles)
+ {
+ return 'bg-tm-green white';
+ }
+ return 'bg-light-gray black';
+ },
+ closemedialib: function()
+ {
+ this.$parent.showmedialib = false;
+ },
+ getBackgroundImage: function(image)
+ {
+ return 'background-image: url(' + this.baseurl + '/' + image.src_thumb + ');width:250px';
+ },
+ getImageUrl(relativeUrl)
+ {
+ return this.baseurl + '/' + relativeUrl;
+ },
+ showImages: function()
+ {
+ this.errors = false;
+ this.showimages = true;
+ this.showfiles = false;
+ this.showimagedetails = false;
+ this.showfiledetails = false;
+ this.imagedetaildata = false;
+ this.detailindex = false;
+ },
+ showFiles: function()
+ {
+ this.showimages = false;
+ this.showfiles = true;
+ this.showimagedetails = false;
+ this.showfiledetails = false;
+ this.imagedetaildata = false;
+ this.filedetaildata = false;
+ this.detailindex = false;
+
+ if(!this.files)
+ {
+ this.errors = false;
+ var filesself = this;
+
+ myaxios.get('/api/v1/medialib/files',{
+ params: {
+ 'url': document.getElementById("path").value,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ filesself.filedata = response.data.files;
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ filesself.errors = error.response.data.errors;
+ }
+ });
+ }
+ },
+ showImageDetails: function(image,index)
+ {
+ this.errors = false;
+ this.showimages = false;
+ this.showfiles = false;
+ this.showimagedetails = true;
+ this.detailindex = index;
+ this.adminurl = myaxios.defaults.baseURL + '/tm/content/visual';
+
+ var imageself = this;
+
+ myaxios.get('/api/v1/image',{
+ params: {
+ 'url': document.getElementById("path").value,
+ 'name': image.name,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ imageself.imagedetaildata = response.data.image;
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ imageself.errors = error.response.data.errors;
+ }
+ });
+ },
+ showFileDetails: function(file,index)
+ {
+ this.errors = false;
+ this.showimages = false;
+ this.showfiles = false;
+ this.showimagedetails = false;
+ this.showfiledetails = true;
+ this.detailindex = index;
+
+ this.adminurl = myaxios.defaults.baseURL + '/tm/content/visual';
+
+ var fileself = this;
+
+ myaxios.get('/api/v1/file',{
+ params: {
+ 'url': document.getElementById("path").value,
+ 'name': file.name,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ fileself.filedetaildata = response.data.file;
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ fileself.errors = error.response.data.errors;
+ }
+ });
+ },
+ selectImage: function(image)
+ {
+ this.showImages();
+
+ if(this.parentcomponent == 'images')
+ {
+ var imgmarkdown = {target: {value: '' }};
+
+ this.$parent.imgfile = image.src_live;
+ this.$parent.imgpreview = this.baseurl + '/' + image.src_live;
+ this.$parent.imgmeta = true;
+
+ this.$parent.showmedialib = false;
+
+ this.$parent.createmarkdown(image.src_live);
+/* this.$parent.updatemarkdown(imgmarkdown, image.src_live); */
+ }
+ if(this.parentcomponent == 'files')
+ {
+ var filemarkdown = {target: {value: '[' + image.name + '](' + image.src_live +'){.tm-download}' }};
+
+ this.$parent.filemeta = true;
+ this.$parent.filetitle = image.name;
+
+ this.$parent.showmedialib = false;
+
+ this.$parent.updatemarkdown(filemarkdown, image.src_live);
+ }
+ },
+ selectFile: function(file)
+ {
+ /* if image component is open */
+ if(this.parentcomponent == 'images')
+ {
+ var imgextensions = ['png','jpg', 'jpeg', 'gif', 'svg', 'webp'];
+ if(imgextensions.indexOf(file.info.extension) == -1)
+ {
+ this.errors = "you cannot insert a file into an image component";
+ return;
+ }
+ var imgmarkdown = {target: {value: '' }};
+
+ this.$parent.imgfile = file.url;
+ this.$parent.imgpreview = file.url;
+ this.$parent.imgmeta = true;
+
+ this.$parent.showmedialib = false;
+
+ this.$parent.createmarkdown(file.url);
+/* this.$parent.updatemarkdown(imgmarkdown, file.url);*/
+ }
+ if(this.parentcomponent == 'files')
+ {
+ var filemarkdown = {target: {value: '['+ file.name +']('+ file.url +'){.tm-download file-' + file.info.extension + '}' }};
+
+ this.$parent.showmedialib = false;
+
+ this.$parent.filemeta = true;
+ this.$parent.filetitle = file.info.filename + ' (' + file.info.extension.toUpperCase() + ')';
+
+ this.$parent.updatemarkdown(filemarkdown, file.url);
+ }
+ this.showFiles();
+ },
+ removeImage: function(index)
+ {
+ this.imagedata.splice(index,1);
+ },
+ removeFile: function(index)
+ {
+ this.filedata.splice(index,1);
+ },
+ deleteImage: function(image, index)
+ {
+ imageself = this;
+
+ myaxios.delete('/api/v1/image',{
+ data: {
+ 'url': document.getElementById("path").value,
+ 'name': image.name,
+ 'index': index,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ imageself.showImages();
+ imageself.removeImage(index);
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ imageself.errors = error.response.data.errors;
+ }
+ });
+ },
+ deleteFile: function(file, index)
+ {
+ fileself = this;
+
+ myaxios.delete('/api/v1/file',{
+ data: {
+ 'url': document.getElementById("path").value,
+ 'name': file.name,
+ 'index': index,
+ 'csrf_name': document.getElementById("csrf_name").value,
+ 'csrf_value': document.getElementById("csrf_value").value,
+ }
+ })
+ .then(function (response)
+ {
+ fileself.showFiles();
+ fileself.removeFile(index);
+ })
+ .catch(function (error)
+ {
+ if(error.response)
+ {
+ fileself.errors = error.response.data.errors;
+ }
+ });
+ },
+ getDate(timestamp)
+ {
+ date = new Date(timestamp * 1000);
+
+ datevalues = {
+ 'year': date.getFullYear(),
+ 'month': date.getMonth()+1,
+ 'day': date.getDate(),
+ 'hour': date.getHours(),
+ 'minute': date.getMinutes(),
+ 'second': date.getSeconds(),
+ };
+ return datevalues.year + '-' + datevalues.month + '-' + datevalues.day;
+ },
+ getSize(bytes)
+ {
+ var i = Math.floor(Math.log(bytes) / Math.log(1024)),
+ sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+
+ return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i];
+ },
+ isChecked: function(classname)
+ {
+ if(this.imgclass == classname)
+ {
+ return ' checked';
+ }
+ },
+ },
+})
diff --git a/system/author/layouts/layout.twig b/system/author/layouts/layout.twig
index 7284f58..b63a8af 100644
--- a/system/author/layouts/layout.twig
+++ b/system/author/layouts/layout.twig
@@ -7,8 +7,6 @@
-
-
@@ -21,44 +19,13 @@
+
+ {{ assets.renderCSS() }}
+
-
+
+ {% include 'partials/symbols.twig' %}
{% include 'partials/navi.twig' %}
@@ -79,11 +46,16 @@
const myaxios = axios.create();
myaxios.defaults.baseURL = "{{ base_url }}";
+
+
+
+ {{ assets.renderJS() }}
+