Skip to content

Commit

Permalink
Merge pull request #5 from spaun299/connect_file_manager_upload
Browse files Browse the repository at this point in the history
Connect file manager upload
  • Loading branch information
spaun299 committed Jul 22, 2015
2 parents 7df30df + 6ee4d4f commit 1ddf190
Show file tree
Hide file tree
Showing 55 changed files with 134 additions and 101 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Virtualenviroment/
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
Expand Down
5 changes: 3 additions & 2 deletions profapp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#from .db import db
from flask import Flask
from profapp.controllers.views import article_bp, index , filemanager_bp
from profapp.controllers.views import article_bp, index, filemanager_bp
from profapp.controllers.ctrl_filemanager import static_bp
#from profapp import views

def create_app(config='config.ProductionDevelopmentConfig'):
Expand All @@ -9,7 +10,7 @@ def create_app(config='config.ProductionDevelopmentConfig'):
#db.init_app(app)

app.add_url_rule('/', 'index', index)

app.register_blueprint(static_bp,url_prefix='/static')
app.register_blueprint(article_bp, url_prefix='/articles')
app.register_blueprint(filemanager_bp, url_prefix='/filemanager')
return app
Expand Down
36 changes: 36 additions & 0 deletions profapp/controllers/ctrl_filemanager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
from time import gmtime, strftime
from stat import *
from flask import jsonify, request, Blueprint

files = os.listdir('/home/viktor/Downloads')
static_bp = Blueprint('static', __name__)

@static_bp.route('/filemanager/bridges/python/ctrl_filemanager.py', methods=['GET', 'POST'])
def ctrl_filemanager():
for params in request.json.values():
if params['mode'] == 'list':
print(listing())
return jsonify(listing())



def listing():

info = []
for file in files:
st = os.stat('/home/viktor/Downloads/'+file)
params = dict()
params['size'] = st[ST_SIZE]
params['date'] = strftime("%Y-%d-%m %X", gmtime(st[ST_MTIME]))
params['name'] = os.path.basename(file)
params['rights'] = 'drwxr-xr-x'
if os.path.isfile('/home/viktor/Downloads/'+file):
params['type'] = 'file'
else :
params['type'] = 'dir'
info.append(params)
file_list = {"result": info}
return file_list


11 changes: 6 additions & 5 deletions profapp/controllers/views.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from flask import render_template, redirect, url_for, request
from flask import render_template, redirect, url_for, request, jsonify
from profapp.controllers.forms import ArticleForm
from profapp.models.articles import Article, ArticleHistory
from profapp.models.users import User
from profapp.models.company import Company
from db_connect import sql_session
#from config import POSTS_PER_PAGE

import os
from flask import Blueprint

article_bp = Blueprint('articles', __name__)
filemanager_bp = Blueprint('filemanager', __name__)

#filemanager_bp = Blueprint('filemanager', __name__,static_folder='../static',static_url_path='')

@article_bp.route('/article/', methods=['GET','POST'])
@article_bp.route('/article/', methods=['GET', 'POST'])
@article_bp.route('/article/<int:page>', methods=['GET', 'POST'])
def article(page=1):

form = ArticleForm()
posts = ArticleHistory.query.filter(ArticleHistory.id==page)
posts = ArticleHistory.query.filter(ArticleHistory.id == page)

if form.validate_on_submit():
article_history=ArticleHistory(form.name.data,form.article.data, 0,
Expand Down Expand Up @@ -46,7 +47,7 @@ def article(page=1):
def index():
return render_template('index.html')

@filemanager_bp.route('/',methods=['GET','POST'])
@filemanager_bp.route('/', methods=['GET', 'POST'])
def filemanager():
#return filemanager_bp.send_static_file('index.html')
return render_template('filemanager.html')
Expand Down
38 changes: 0 additions & 38 deletions profapp/static/angular-filemanager/.bower.json

This file was deleted.

39 changes: 0 additions & 39 deletions profapp/static/angular-filemanager/assets/js/config.js

This file was deleted.

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions profapp/static/filemanager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'viktor'
File renamed without changes.
39 changes: 39 additions & 0 deletions profapp/static/filemanager/assets/js/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(function(angular) {
"use strict";
angular.module('FileManagerApp').constant("fileManagerConfig", {
appName: "https://github.com/joni2back/angular-filemanager",
defaultLang: "en",

listUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
uploadUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
renameUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
copyUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
removeUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
editUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
getContentUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
createFolderUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
downloadFileUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
compressUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
extractUrl: "/filemanager/bridges/python/ctrl_filemanager.py",
permissionsUrl: "/filemanager/bridges/python/ctrl_filemanager.py",

allowedActions: {
rename: true,
copy: true,
edit: true,
changePermissions: true,
compress: true,
compressChooseName: true,
extract: true,
download: true,
preview: true,
remove: true
},

enablePermissionsRecursive: true,

isEditableFilePattern: '\\.(txt|html|htm|aspx|asp|ini|pl|py|md|php|css|js|log|htaccess|htpasswd|json|sql|xml|xslt|sh|rb|as|bat|cmd|coffee|php[3-6]|java|c|cbl|go|h|scala|vb)$',
isImageFilePattern: '\\.(jpg|jpeg|gif|bmp|png|svg|tiff)$',
isExtractableFilePattern: '\\.(zip|gz|tar|rar|gzip)$'
});
})(angular);
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
var FileNavigator = function() {
this.requesting = false;
this.fileList = [];
this.currentPath = [];
this.currentPath =[];
this.history = [];
this.error = '';
};
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions profapp/static/filemanager/bridges/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'viktor'
1 change: 1 addition & 0 deletions profapp/static/filemanager/bridges/pyhon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'viktor'
Empty file.
File renamed without changes.
5 changes: 5 additions & 0 deletions profapp/static/filemanager/dist/angular-filemanager.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions profapp/static/filemanager/dist/angular-filemanager.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 1ddf190

Please sign in to comment.