Skip to content

Commit

Permalink
Add Gruntfile.js for concat+uglification of javascript
Browse files Browse the repository at this point in the history
Enable debug=true cookie for full source inclusion in header.php
Add template in header.php to inject generated javascript files
  • Loading branch information
jekkos committed Mar 15, 2015
1 parent c10860a commit aa65593
Show file tree
Hide file tree
Showing 9 changed files with 15,523 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
bower_components
application/config/email.php
application/config/database.php
*.patch
Expand Down
76 changes: 76 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['js/jquery*', 'js/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
jshint: {
files: ['Gruntfile.js', 'js/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
tags: {
js : {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}" language="javascript"></script>',
openTag: '<!-- start js template tags -->',
closeTag: '<!-- end js template tags -->',
absolutePath: true
},
src: [
'js/*.js',
],
dest: 'application/views/partial/header.php'
},
minjs : {
options: {
scriptTemplate: '<script type="text/javascript" src="{{ path }}" language="javascript"></script>',
openTag: '<!-- start minjs template tags -->',
closeTag: '<!-- end minjs template tags -->',
absolutePath: true
},
src: [
'dist/*min.js',
],
dest: 'application/views/partial/header.php'
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-script-link-tags');

grunt.registerTask('default', ['tags:js', 'tags:css', 'concat', 'uglify', 'tags:minjs']);

};
2 changes: 0 additions & 2 deletions application/config/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@
'filename' => 'load_config.php',
'filepath' => 'hooks'
);


/* End of file hooks.php */
/* Location: ./application/config/hooks.php */
3 changes: 0 additions & 3 deletions application/views/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Open Source Point Of Sale <?php echo $this->lang->line('login_login'); ?></title>
<script src="<?php echo base_url();?>js/jquery-1.8.3.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script type="text/javascript" src="js/slidetounlock/slider.js"></script>

<script src="<?php echo base_url();?>js/index.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function()
{
Expand Down
52 changes: 30 additions & 22 deletions application/views/partial/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,36 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="<?php echo base_url();?>" />
<title><?php echo $this->config->item('company').' -- '.$this->lang->line('common_powered_by').' OS Point Of Sale' ?></title>
<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/ospos.css" />
<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/ospos_print.css" media="print"/>
<script>BASE_URL = '<?php echo site_url(); ?>';</script>
<script src="<?php echo base_url();?>js/jquery-1.8.3.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/imgpreview.full.jquery.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/datepicker.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.color.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.metadata.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.form-3.51.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.tablesorter.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.ajax_queue.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.bgiframe.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.autocomplete.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.validate-1.13.1-min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.jkey-1.1.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/nominatim.autocomplete.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/thickbox.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/common.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/manage_tables.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/swfobject.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/date.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/datepicker.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="css/ospos.css"/>
<link rel="stylesheet" type="text/css" href="css/ospos_print.css" media="print" />
<?php if ($this->input->cookie('debug') == "true" || $this->input->post("debug") == "true") : ?>
<!-- start js template tags -->
<script type="text/javascript" src="js/common.js" language="javascript"></script>
<script type="text/javascript" src="js/date.js" language="javascript"></script>
<script type="text/javascript" src="js/datepicker.js" language="javascript"></script>
<script type="text/javascript" src="js/imgpreview.full.jquery.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery-1.8.3.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery-migrate-1.2.1.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.ajax_queue.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.bgiframe.min.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.color.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.form-3.51.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.jkey-1.1.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.metadata.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.tablesorter.min.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.validate-1.13.1-min.js" language="javascript"></script>
<script type="text/javascript" src="js/manage_tables.js" language="javascript"></script>
<script type="text/javascript" src="js/nominatim.autocomplete.js" language="javascript"></script>
<script type="text/javascript" src="js/swfobject.js" language="javascript"></script>
<script type="text/javascript" src="js/tabcontent.js" language="javascript"></script>
<script type="text/javascript" src="js/thickbox.js" language="javascript"></script>
<!-- end js template tags -->
<?php else : ?>
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js" language="javascript"></script>
<!-- end minjs template tags -->
<?php endif; ?>
<script type="text/javascript">
function logout(logout)
{
Expand Down
Loading

0 comments on commit aa65593

Please sign in to comment.