Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
03aa0d64
Commit
03aa0d64
authored
Feb 09, 2016
by
Vassilis Kanellopoulos
Browse files
schools module; assets manager
parent
89d81d23
Changes
25
Hide whitespace changes
Inline
Side-by-side
config/app.config.php
View file @
03aa0d64
...
...
@@ -10,11 +10,13 @@
return
[
'modules'
=>
[
'module/assets_manager/bootstrap.php'
,
'module/authentication/bootstrap.php'
,
'module/authorization/bootstrap.php'
,
// 'module/sch_ldap/bootstrap.php',
'module/sch_sso/bootstrap.php'
,
// 'module/sch_auto_create/bootstrap.php',
'module/schools/bootstrap.php'
,
'module/application/bootstrap.php'
,
],
'cache_config'
=>
'data/cache/config/settings.php'
,
...
...
config/settings/acl.global.php
View file @
03aa0d64
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
[
'acl'
=>
[
...
...
@@ -14,11 +21,6 @@ return [
'callables'
=>
[],
'routes'
=>
[
[
'/'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school/labs'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school/staff'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school/assets'
,
[
'guest'
,
'user'
],
[
'get'
]],
],
],
],
...
...
config/settings/assets_manager.global.php
0 → 100644
View file @
03aa0d64
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
[
'assets'
=>
[
'web_dir'
=>
'public'
,
'paths'
=>
[
'module/schools/public'
,
],
],
];
config/settings/authentication.global.php
View file @
03aa0d64
...
...
@@ -16,4 +16,4 @@ return [
],
],
],
];
\ No newline at end of file
];
config/settings/schools.global.php
0 → 100644
View file @
03aa0d64
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
[
'acl'
=>
[
'guards'
=>
[
'routes'
=>
[
[
'/school'
,
[
'user'
],
[
'get'
]],
[
'/school/labs'
,
[
'user'
],
[
'get'
]],
[
'/school/staff'
,
[
'user'
],
[
'get'
]],
[
'/school/assets'
,
[
'user'
],
[
'get'
]],
],
],
],
];
module/application/bootstrap.php
View file @
03aa0d64
...
...
@@ -67,21 +67,7 @@ return function (Slim\App $app) {
return
new
GrEduLabs\Application\Action\Index
(
$c
[
'view'
]);
};
$container
[
'GrEduLabs\\Application\\Action\\School\\Index'
]
=
function
(
$c
)
{
return
new
GrEduLabs\Application\Action\School\Index
(
$c
->
get
(
'view'
));
};
$container
[
'GrEduLabs\\Application\\Action\\School\\Staff'
]
=
function
(
$c
)
{
return
new
GrEduLabs\Application\Action\School\Staff
(
$c
->
get
(
'view'
));
};
$container
[
'GrEduLabs\\Application\\Action\\School\\Labs'
]
=
function
(
$c
)
{
return
new
GrEduLabs\Application\Action\School\Labs
(
$c
->
get
(
'view'
));
};
$container
[
'GrEduLabs\\Application\\Action\\School\\Assets'
]
=
function
(
$c
)
{
return
new
GrEduLabs\Application\Action\School\Assets
(
$c
->
get
(
'view'
));
};
$events
=
$container
[
'events'
];
$events
(
'on'
,
'bootstrap'
,
function
()
use
(
$container
)
{
...
...
@@ -110,10 +96,5 @@ return function (Slim\App $app) {
$app
->
get
(
'/'
,
'GrEduLabs\\Application\\Action\\Index'
)
->
setName
(
'index'
);
$app
->
group
(
'/school'
,
function
()
{
$this
->
get
(
''
,
'GrEduLabs\\Application\\Action\\School\\Index'
)
->
setName
(
'school'
);
$this
->
get
(
'/staff'
,
'GrEduLabs\\Application\\Action\\School\\Staff'
)
->
setName
(
'school.staff'
);
$this
->
get
(
'/labs'
,
'GrEduLabs\\Application\\Action\\School\\Labs'
)
->
setName
(
'school.labs'
);
$this
->
get
(
'/assets'
,
'GrEduLabs\\Application\\Action\\School\\Assets'
)
->
setName
(
'school.assets'
);
});
};
module/assets_manager/bootstrap.php
0 → 100644
View file @
03aa0d64
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
Slim\Http\Response
;
return
function
(
Slim
\
App
$app
)
{
$mimeTypes
=
[
'txt'
=>
'text/plain'
,
'htm'
=>
'text/html'
,
'html'
=>
'text/html'
,
'php'
=>
'text/html'
,
'css'
=>
'text/css'
,
'js'
=>
'application/javascript'
,
'json'
=>
'application/json'
,
'xml'
=>
'application/xml'
,
'swf'
=>
'application/x-shockwave-flash'
,
'flv'
=>
'video/x-flv'
,
// images
'png'
=>
'image/png'
,
'jpe'
=>
'image/jpeg'
,
'jpeg'
=>
'image/jpeg'
,
'jpg'
=>
'image/jpeg'
,
'gif'
=>
'image/gif'
,
'bmp'
=>
'image/bmp'
,
'ico'
=>
'image/vnd.microsoft.icon'
,
'tiff'
=>
'image/tiff'
,
'tif'
=>
'image/tiff'
,
'svg'
=>
'image/svg+xml'
,
'svgz'
=>
'image/svg+xml'
,
// archives
'zip'
=>
'application/zip'
,
'rar'
=>
'application/x-rar-compressed'
,
'exe'
=>
'application/x-msdownload'
,
'msi'
=>
'application/x-msdownload'
,
'cab'
=>
'application/vnd.ms-cab-compressed'
,
// audio/video
'mp3'
=>
'audio/mpeg'
,
'qt'
=>
'video/quicktime'
,
'mov'
=>
'video/quicktime'
,
// adobe
'pdf'
=>
'application/pdf'
,
'psd'
=>
'image/vnd.adobe.photoshop'
,
'ai'
=>
'application/postscript'
,
'eps'
=>
'application/postscript'
,
'ps'
=>
'application/postscript'
,
// ms office
'doc'
=>
'application/msword'
,
'rtf'
=>
'application/rtf'
,
'xls'
=>
'application/vnd.ms-excel'
,
'ppt'
=>
'application/vnd.ms-powerpoint'
,
// open office
'odt'
=>
'application/vnd.oasis.opendocument.text'
,
'ods'
=>
'application/vnd.oasis.opendocument.spreadsheet'
,
];
$container
=
$app
->
getContainer
();
$events
=
$container
[
'events'
];
$events
(
'on'
,
'bootstrap'
,
function
()
use
(
$app
,
$container
,
$mimeTypes
)
{
$app
->
add
(
function
(
ServerRequestInterface
$req
,
ResponseInterface
$res
,
callable
$next
)
use
(
$mimeTypes
,
$container
)
{
$res
=
$next
(
$req
,
$res
);
if
(
404
===
$res
->
getStatusCode
())
{
$settings
=
$container
[
'settings'
][
'assets'
];
$file
=
array_reduce
(
$settings
[
'paths'
],
function
(
$file
,
$path
)
use
(
$req
)
{
if
(
false
!==
$file
)
{
return
$file
;
}
$file
=
$path
.
$req
->
getUri
()
->
getPath
();
if
(
is_readable
(
$file
))
{
return
$file
;
}
return
false
;
},
false
);
if
(
!
$file
)
{
return
$res
;
}
$ext
=
strtolower
(
array_pop
(
explode
(
'.'
,
$file
)));
$mime
=
array_key_exists
(
$ext
,
$mimeTypes
)
?
$mimeTypes
[
$ext
]
:
mime_content_type
(
$file
);
$contents
=
file_get_contents
(
$file
);
if
(
is_writable
(
$settings
[
'web_dir'
]))
{
$destFile
=
$settings
[
'web_dir'
]
.
$req
->
getUri
()
->
getPath
();
$destPath
=
dirname
(
$destFile
);
if
(
!
is_dir
(
$destPath
))
{
mkdir
(
$destPath
);
}
file_put_contents
(
$destFile
,
$contents
);
}
$res
=
new
Response
(
200
);
$res
->
withHeader
(
'Content-Type'
,
$mime
);
$res
->
getBody
()
->
write
(
$contents
);
}
return
$res
;
});
},
-
10000
);
};
module/authorization/src/RouteGuard.php
View file @
03aa0d64
...
...
@@ -38,7 +38,7 @@ class RouteGuard
public
function
__invoke
(
RequestInterface
$request
,
ResponseInterface
$response
,
callable
$next
)
{
if
(
!
$request
->
getAttribute
(
'route'
))
{
return
$response
->
withStatus
(
500
);
return
$response
->
withStatus
(
404
);
}
$isAllowed
=
false
;
if
(
$this
->
acl
->
hasResource
(
'route'
.
$request
->
getAttribute
(
'route'
)
->
getPattern
()))
{
...
...
module/schools/bootstrap.php
0 → 100644
View file @
03aa0d64
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
function
(
Slim
\
App
$app
)
{
$container
=
$app
->
getContainer
();
$container
[
'autoloader'
]
->
addPsr4
(
'GrEduLabs\\Schools\\'
,
__DIR__
.
'/src/'
);
$container
[
GrEduLabs\Schools\Action\Index
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Index
(
$c
->
get
(
'view'
));
};
$container
[
GrEduLabs\Schools\Action\Staff
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Staff
(
$c
->
get
(
'view'
));
};
$container
[
GrEduLabs\Schools\Action\Labs
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Labs
(
$c
->
get
(
'view'
));
};
$container
[
GrEduLabs\Schools\Action\Assets
::
class
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Action\Assets
(
$c
->
get
(
'view'
));
};
$events
=
$container
[
'events'
];
$events
(
'on'
,
'bootstrap'
,
function
()
use
(
$container
)
{
$container
[
'view'
]
->
getEnvironment
()
->
getLoader
()
->
prependPath
(
__DIR__
.
'/templates'
);
});
$app
->
group
(
'/school'
,
function
()
{
$this
->
get
(
''
,
GrEduLabs\Schools\Action\Index
::
class
)
->
setName
(
'school'
);
$this
->
get
(
'/staff'
,
GrEduLabs\Schools\Action\Staff
::
class
)
->
setName
(
'school.staff'
);
$this
->
get
(
'/labs'
,
GrEduLabs\Schools\Action\Labs
::
class
)
->
setName
(
'school.labs'
);
$this
->
get
(
'/assets'
,
GrEduLabs\Schools\Action\Assets
::
class
)
->
setName
(
'school.assets'
);
});
};
public/js/school/assets.js
→
module/schools/
public/js/school
s
/assets.js
View file @
03aa0d64
File moved
public/js/school/index.js
→
module/schools/
public/js/school
s
/index.js
View file @
03aa0d64
File moved
public/js/school/labs.js
→
module/schools/
public/js/school
s
/labs.js
View file @
03aa0d64
File moved
public/js/school/staff.js
→
module/schools/
public/js/school
s
/staff.js
View file @
03aa0d64
File moved
module/
application
/src/Action/
School/
Assets.php
→
module/
schools
/src/Action/Assets.php
View file @
03aa0d64
...
...
@@ -8,7 +8,7 @@
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\
Application\Action\School
;
namespace
GrEduLabs\
Schools\Action
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
...
...
@@ -25,7 +25,7 @@ class Assets
public
function
__invoke
(
Request
$req
,
Response
$res
,
array
$args
=
[])
{
return
$this
->
view
->
render
(
$res
,
'school/assets.twig'
,
[
return
$this
->
view
->
render
(
$res
,
'school
s
/assets.twig'
,
[
'assets'
=>
[
[
'id'
=>
1
,
...
...
module/
application
/src/Action/
School/
Index.php
→
module/
schools
/src/Action/Index.php
View file @
03aa0d64
...
...
@@ -8,7 +8,7 @@
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\
Application\Action\School
;
namespace
GrEduLabs\
Schools\Action
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
...
...
@@ -25,6 +25,6 @@ class Index
public
function
__invoke
(
Request
$req
,
Response
$res
,
array
$args
=
[])
{
return
$this
->
view
->
render
(
$res
,
'school/index.twig'
);
return
$this
->
view
->
render
(
$res
,
'school
s
/index.twig'
);
}
}
module/
application
/src/Action/
School/
Labs.php
→
module/
schools
/src/Action/Labs.php
View file @
03aa0d64
...
...
@@ -8,7 +8,7 @@
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\
Application\Action\School
;
namespace
GrEduLabs\
Schools\Action
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
...
...
@@ -25,7 +25,7 @@ class Labs
public
function
__invoke
(
Request
$req
,
Response
$res
,
array
$args
=
[])
{
return
$this
->
view
->
render
(
$res
,
'school/labs.twig'
,
[
return
$this
->
view
->
render
(
$res
,
'school
s
/labs.twig'
,
[
'labs'
=>
[
[
'id'
=>
1
,
...
...
module/
application
/src/Action/
School/
Staff.php
→
module/
schools
/src/Action/Staff.php
View file @
03aa0d64
...
...
@@ -8,7 +8,7 @@
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\
Application\Action\School
;
namespace
GrEduLabs\
Schools\Action
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
...
...
@@ -25,7 +25,7 @@ class Staff
public
function
__invoke
(
Request
$req
,
Response
$res
,
array
$args
=
[])
{
return
$this
->
view
->
render
(
$res
,
'school/staff.twig'
,
[
return
$this
->
view
->
render
(
$res
,
'school
s
/staff.twig'
,
[
'staff'
=>
array_fill
(
0
,
1
,
[
'id'
=>
150
,
...
...
module/
application
/templates/school/assets.twig
→
module/
schools
/templates/school
s
/assets.twig
View file @
03aa0d64
{%
extends
"school/index.twig"
%}
{%
extends
"school
s
/index.twig"
%}
{%
import
"school/index.twig"
as
macros
%}
{%
import
"school
s
/index.twig"
as
macros
%}
{%
block
schoolTitle
%}
{{
parent
()
}}
<small>
Εξοπλισμός
</small>
...
...
@@ -85,5 +85,5 @@
{%
block
inlinejs
%}
{{
parent
()
}}
<script
src=
"
{{
base_url
}}
/js/school/assets.js"
></script>
<script
src=
"
{{
base_url
}}
/js/school
s
/assets.js"
></script>
{%
endblock
%}
\ No newline at end of file
module/
application
/templates/school/index.twig
→
module/
schools
/templates/school
s
/index.twig
View file @
03aa0d64
...
...
@@ -150,5 +150,5 @@
{%
block
inlinejs
%}
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"
></script>
<script
type=
"text/javascript"
src=
"
{{
base_url
}}
/js/school/index.js"
></script>
<script
type=
"text/javascript"
src=
"
{{
base_url
}}
/js/school
s
/index.js"
></script>
{%
endblock
%}
\ No newline at end of file
module/
application
/templates/school/labs.twig
→
module/
schools
/templates/school
s
/labs.twig
View file @
03aa0d64
{%
extends
"school/index.twig"
%}
{%
extends
"school
s
/index.twig"
%}
{%
import
"school/index.twig"
as
macros
%}
{%
import
"school
s
/index.twig"
as
macros
%}
{%
block
schoolTitle
%}
{{
parent
()
}}
<small>
Χώροι
</small>
...
...
@@ -91,5 +91,5 @@
{%
block
inlinejs
%}
{{
parent
()
}}
<script
src=
"
{{
base_url
}}
/js/school/labs.js"
></script>
<script
src=
"
{{
base_url
}}
/js/school
s
/labs.js"
></script>
{%
endblock
%}
\ No newline at end of file
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment