├── .gitignore ├── LICENSE ├── README.md ├── app ├── assets │ └── .gitkeep ├── config.coffee ├── controllers │ ├── .gitkeep │ └── example-controller.coffee ├── helpers.coffee ├── initialize.coffee ├── routes.coffee ├── start.coffee ├── validators.coffee └── views │ ├── .gitkeep │ └── hello.eco ├── bower.json ├── brunch-config.coffee ├── core ├── bootstrap.coffee ├── controller.coffee └── view.coffee ├── package.json └── vendor └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.orig 5 | *.log 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *~ 11 | *.sass-cache 12 | 13 | # OS or Editor folders 14 | .DS_Store 15 | .cache 16 | .project 17 | .settings 18 | .tmproj 19 | nbproject 20 | Thumbs.db 21 | 22 | # NPM packages folder. 23 | node_modules/ 24 | 25 | # Brunch folder for temporary files. 26 | tmp/ 27 | 28 | # Brunch output folder. 29 | public/ 30 | 31 | # Bower stuff. 32 | bower_components/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](http://gothamjs.io/share.png) 2 | 3 | # Notes 4 | 5 | This project is quite outdated, still it's working on production for some web applications I built for companies. I will convert the website into a wiki when I will find a bit of time :) 6 | 7 | # Gotham JS Framework 8 | 9 | Gotham is a web application framework for front-end development. After crafting many web applications using Laravel and Rails I couldn't find a simple front-end framework to manage my Javascript. I wanted to code my front-end with an expressive syntax, install a package and use it without any pain. To require/include functions like you can in others languages, execute something when i need it, and do it all in an elegant, logical way. 10 | 11 | Gotham was born. 12 | 13 | # Official Documentation 14 | 15 | Documentation for the framework can be found on the [Gotham website](http://gothamjs.io/documentation). 16 | 17 | # Community 18 | 19 | ### Chat 20 | [![Join the chat at https://gitter.im/gothamjs/framework](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gothamjs/framework?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 21 | 22 | Want to speak with me or the community ? Join us on Gitter. 23 | 24 | ### Bugs 25 | You found a bug ? Let me know. 26 | 27 | # License 28 | 29 | The Gotham framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) 30 | -------------------------------------------------------------------------------- /app/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gothamjs/framework/92fd1e1bcd291c0c51033fc7923f021c74beaf95/app/assets/.gitkeep -------------------------------------------------------------------------------- /app/config.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Config 3 | #-------------------------------------------------------------------------- 4 | # 5 | # Sometimes you need to put some configuration variables for your project, 6 | # here it's the right place for that ! 7 | # 8 | # Config = require 'config' 9 | # console.log Config.app.name 10 | ## 11 | 12 | module.exports = 13 | 14 | # Example 15 | app: 16 | name: 'My Gotham Application' 17 | version: 0.1 18 | -------------------------------------------------------------------------------- /app/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | .gitkeep -------------------------------------------------------------------------------- /app/controllers/example-controller.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Example Controller 3 | #-------------------------------------------------------------------------- 4 | # 5 | # That controller is just an example. 6 | # 7 | # @see http://gothamjs.io/documentation/1.0.0/controllers 8 | ## 9 | 10 | # Require the controller library of Gotham 11 | Controller = require 'core/controller' 12 | 13 | 14 | class Example extends Controller 15 | 16 | ## 17 | # Before 18 | # 19 | # Executed before the run action. You can use 20 | # @stop() in this method to stop the execution 21 | # of the controller 22 | # 23 | ## 24 | before: -> 25 | 26 | ## 27 | # Run 28 | # 29 | # The main entry of the controller. 30 | # Your code start here 31 | # 32 | ## 33 | run: -> 34 | 35 | 36 | # Export 37 | module.exports = Example 38 | -------------------------------------------------------------------------------- /app/helpers.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Helpers 3 | #-------------------------------------------------------------------------- 4 | # 5 | # If you need to create some functions to use in your application, you are 6 | # in the right place ! 7 | # 8 | # Gotham uses lo-dash and the concept of mixins. 9 | # 10 | # @see http://gothamjs.iodocumentation/1.0.0/helpers 11 | ## 12 | 13 | ## 14 | # Example 15 | # 16 | # Check if the user is batman 17 | # 18 | # @param [string] Name of the user 19 | ## 20 | _.mixin isBatman: (name) -> 21 | 22 | if name.toLowerCase() is "batman" 23 | return true 24 | 25 | return false 26 | -------------------------------------------------------------------------------- /app/initialize.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Initialize 3 | #-------------------------------------------------------------------------- 4 | # 5 | # It's the main entry of your gotham application. We will require the 6 | # bootstrap file and run gotham. 7 | ## 8 | Bootstrap = require 'core/bootstrap' 9 | 10 | # Hey sir, is the document ready ? 11 | $ -> 12 | 13 | # Yep ! We will run gotham ! 14 | bootstrap = new Bootstrap 15 | 16 | # We set the browser's request 17 | request: window.location.pathname 18 | 19 | bootstrap.run() 20 | -------------------------------------------------------------------------------- /app/routes.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Routes 3 | #-------------------------------------------------------------------------- 4 | # 5 | # All routes of your application. 6 | # 7 | # @see http://gothamjs.io/documentation/1.0.0/routing 8 | ## 9 | 10 | module.exports = (route) -> 11 | 12 | #-------------------------------------------------------------------------- 13 | # Basic routing 14 | #-------------------------------------------------------------------------- 15 | # 16 | # route.match '/welcome', -> 17 | # 18 | # console.log "Hello" 19 | # 20 | # If the url is like www.domain.com/welcome, gotham will 21 | # display "Hello" in the console log. 22 | # 23 | # @see http://gothamjs.io/documentation/1.0.0/routing#basic-routing 24 | ## 25 | 26 | 27 | #-------------------------------------------------------------------------- 28 | # Route parameters 29 | #-------------------------------------------------------------------------- 30 | # 31 | # route.match '/users/show/:id', (params) -> 32 | # 33 | # console.log 'User #' + params.id 34 | # 35 | # If the url is like www.domain.com/users/show/3, gotham will 36 | # display "User #3" in the console log. 37 | # 38 | # @see http://gothamjs.io/documentation/1.0.0/routing#route-parameters 39 | ## 40 | 41 | #-------------------------------------------------------------------------- 42 | # Routing to controllers 43 | #-------------------------------------------------------------------------- 44 | # 45 | # route.match '/kill-batman', 'batman.kill' 46 | # 47 | # If the url is like www.domain.com/kill-batman, gotham will 48 | # execute the controller app/controllers/batman/kill.coffee 49 | # 50 | # @see http://gothamjs.io/documentation/1-0-0/controllers#route 51 | ## 52 | 53 | #-------------------------------------------------------------------------- 54 | # Route constraints 55 | #-------------------------------------------------------------------------- 56 | # 57 | # route.match '/kill/:name', 'batman.kill', (params) -> 58 | # 59 | # if params.name is 'Batman' 60 | # return true 61 | # 62 | # return false 63 | # 64 | # If the url is like www.domain.com/kill/joker, gotham will not 65 | # execute the controller app/controllers/batman/kill.coffee 66 | # 67 | # @see http://gothamjs.io/documentation/1.0.0/routing#route-constraints 68 | ## 69 | -------------------------------------------------------------------------------- /app/start.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Start 3 | #-------------------------------------------------------------------------- 4 | # 5 | # Gotham will run after that file the router system. It's the right place 6 | # to put some code to execute globally like the init of jQuery plugins, etc. 7 | ## 8 | 9 | #-------------------------------------------------------------------------- 10 | # Example 11 | #-------------------------------------------------------------------------- 12 | # 13 | # We want to say hello to the developer :) 14 | ## 15 | 16 | # Load library View of Gotham 17 | View = require 'core/view' 18 | 19 | # Invoke View 20 | view = new View() 21 | 22 | # Load view 23 | hello = view.render 'hello', {framework: 'Gotham'} 24 | 25 | # Inject in the html 26 | $('body').html hello 27 | -------------------------------------------------------------------------------- /app/validators.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Errors 3 | #-------------------------------------------------------------------------- 4 | # 5 | # If you want to change / add errors for the Validator library, you can 6 | # do it here. 7 | # 8 | # @see http://gothamjs.io/documentation/1.0.0/validator#custom-error 9 | ## 10 | Validator.errors 11 | 12 | #-------------------------------------------------------------------------- 13 | # Attributes 14 | #-------------------------------------------------------------------------- 15 | # 16 | # If you want to change / add attributes for the Validator library, you can 17 | # do it here. 18 | # 19 | # @see http://gothamjs.io/documentation/1.0.0/validator#change-attributes 20 | ## 21 | Validator.attributes 22 | -------------------------------------------------------------------------------- /app/views/.gitkeep: -------------------------------------------------------------------------------- 1 | .gitkeep -------------------------------------------------------------------------------- /app/views/hello.eco: -------------------------------------------------------------------------------- 1 | 62 | 63 |
64 | 65 | 66 |

<%- @framework %>

67 |

You just loaded Gotham, it's an impressive start.

68 |

I'm executed by `start.coffee` and you can find me in `views/hello.eco`

69 | Documentation 70 |
71 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Your Gotham's application", 3 | "version": "0.0.1", 4 | "main": "", 5 | "dependencies": { 6 | "console-polyfill": "~0.1.2", 7 | "jquery": "2.1.3", 8 | "lodash": "~3.9.0", 9 | "gotham-router": "~1.0.0", 10 | "gotham-syphon": "~1.0.0", 11 | "gotham-validator": "~1.0.0", 12 | "gotham-validator-rules": "~1.0.0" 13 | }, 14 | "overrides": {} 15 | } 16 | -------------------------------------------------------------------------------- /brunch-config.coffee: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------- 2 | # Brunch Config 3 | #-------------------------------------------------------------------------- 4 | # 5 | # It's the brunch configuration for Gotham. 6 | # 7 | # @see https://github.com/brunch/brunch/blob/stable/docs/config.md 8 | # 9 | ## 10 | exports.config = 11 | 12 | #-------------------------------------------------------------------------- 13 | # Paths 14 | #-------------------------------------------------------------------------- 15 | # 16 | # Contains application paths to key directories. Paths are simple strings. 17 | # 18 | # @see https://github.com/brunch/brunch/blob/stable/docs/config.md#paths 19 | ## 20 | paths: 21 | 22 | # Path to build directory that would contain output. 23 | public: 'public' 24 | 25 | # List of all watched paths by brunch. 26 | watched: ['app', 'vendor', 'core'] 27 | 28 | #-------------------------------------------------------------------------- 29 | # Files 30 | #-------------------------------------------------------------------------- 31 | # 32 | # Configures handling of application files: 33 | # - Which compiler would be used on which file 34 | # - What name should output file have, etc ... 35 | # 36 | # Any paths specified here must be listed in paths.watched as described above, 37 | # for building. 38 | # 39 | # @see https://github.com/brunch/brunch/blob/stable/docs/config.md#files 40 | ## 41 | files: 42 | 43 | javascripts: 44 | 45 | joinTo: 46 | 'javascripts/app.js': /^(core|app)/ 47 | 'javascripts/vendor.js': /^(vendor|bower_components)/ 48 | 49 | order: 50 | before: [] 51 | after: [] 52 | 53 | stylesheets: 54 | 55 | joinTo: 56 | 'stylesheets/vendor.css': /^(vendor|bower_components)/ 57 | 58 | order: 59 | before: [] 60 | after: [] 61 | 62 | templates: 63 | joinTo: 'javascripts/app.js' 64 | 65 | #-------------------------------------------------------------------------- 66 | # Notifications 67 | #-------------------------------------------------------------------------- 68 | # 69 | # Enables or disables notifications of: 70 | # - Growl 71 | # - Growl for Windows 72 | # - terminal-notifier 73 | # - libnotify 74 | # 75 | # 76 | # @see https://github.com/brunch/brunch/blob/stable/docs/config.md#files 77 | ## 78 | notifications: true 79 | 80 | #-------------------------------------------------------------------------- 81 | # Notifications Title 82 | #-------------------------------------------------------------------------- 83 | # 84 | # Sets the title used in notifications 85 | # 86 | # @see https://github.com/brunch/brunch/blob/stable/docs/config.md#notificationstitle 87 | ## 88 | notificationsTitle: 'Gotham' 89 | -------------------------------------------------------------------------------- /core/bootstrap.coffee: -------------------------------------------------------------------------------- 1 | ## 2 | # Bootstrap 3 | # 4 | # Skeleton of gotham 5 | ## 6 | class Bootstrap 7 | 8 | ## 9 | # Constructor 10 | # 11 | # The constructor 12 | # 13 | ## 14 | constructor: (options) -> 15 | 16 | @options = options 17 | 18 | ## 19 | # Run 20 | # 21 | # Load the helpers, start, init the router, 22 | # run the router and execute a callback or 23 | # a controller. 24 | # 25 | ## 26 | run: -> 27 | 28 | # Load lo-dash helpers 29 | require 'helpers' 30 | 31 | # Load custom validators 32 | require 'validators' 33 | 34 | # Load start 35 | require 'start' 36 | 37 | # Init router 38 | router = new Router(@options.request) 39 | 40 | # Load routes 41 | require('routes')(router) 42 | 43 | # Run router 44 | router.run() 45 | 46 | # Check response 47 | if router.passes() 48 | 49 | # Stock response 50 | response = router.response() 51 | 52 | # Stock params 53 | params = response.params 54 | 55 | # Check if we need to call directly the callback 56 | if _.isFunction(response.result) 57 | 58 | # Call it ! 59 | response.result(params) 60 | 61 | else 62 | 63 | # Convert string to the path 64 | path = @_formatPath(response.result) 65 | 66 | # Require controller 67 | controller = require 'controllers/' + path 68 | 69 | # Invoke 70 | controller = new controller() 71 | 72 | # Check if we have a method before 73 | if controller['before']? 74 | 75 | # Run the before method 76 | controller.before(params) 77 | 78 | unless controller._gothamStop 79 | controller.run(params) 80 | 81 | ## 82 | # Format path 83 | # 84 | # Will replace all dots by a slash 85 | # 86 | # @param [String] The string to format 87 | # 88 | ## 89 | _formatPath: (str) -> 90 | 91 | str.split('.').join('/') 92 | 93 | 94 | module.exports = Bootstrap 95 | -------------------------------------------------------------------------------- /core/controller.coffee: -------------------------------------------------------------------------------- 1 | View = require 'core/view' 2 | 3 | ## 4 | # Controller 5 | # 6 | # Basic controller structure. 7 | ## 8 | class Controller 9 | 10 | # Flag to know if we must run or not the controller 11 | # It's linked with the before() method. 12 | _gothamStop: false 13 | 14 | ## 15 | # Constructor 16 | # 17 | # The constructor 18 | # 19 | ## 20 | constructor: -> 21 | 22 | ## 23 | # Stop 24 | # 25 | # If we call this method in the before method, 26 | # it will not execute the run() method 27 | # 28 | ## 29 | stop: -> 30 | 31 | @_gothamStop = true 32 | 33 | ## 34 | # Log 35 | # 36 | # Shortcut to display a console.log 37 | # 38 | # @param [Mixed] Value to display 39 | # 40 | ## 41 | log: (value) -> 42 | 43 | console.log(value) 44 | 45 | ## 46 | # On 47 | # 48 | # Shortcut to create a jquery "on" event 49 | # 50 | # @param [String] Trigger to listen (Ex. click) 51 | # @param [String] The selector to attach 52 | # @param [Function] The callback 53 | # 54 | ## 55 | on: (trigger, selector, handler) -> 56 | 57 | $(selector).on trigger, handler 58 | 59 | ## 60 | # Off 61 | # 62 | # Shortcut to create a jquery "off" event 63 | # 64 | # @param [String] Trigger to shutdown (Ex. click) 65 | # @param [String] The selector attached 66 | # @param [Function] The handler 67 | # 68 | ## 69 | off: (trigger, selector, handler) -> 70 | 71 | $(selector).off trigger, handler 72 | 73 | ## 74 | # Delayed 75 | # 76 | # Like "on" jquery event but listen new elements 77 | # added in the page 78 | # 79 | # @param [String] Trigger to listen (Ex. click) 80 | # @param [String] The selector to attach 81 | # @param [Function] The callback 82 | # 83 | ## 84 | delayed: (trigger, selector, handler) -> 85 | 86 | $(document).on trigger, selector, handler 87 | 88 | ## 89 | # View 90 | # 91 | # Shortcut to render a view 92 | # 93 | # @param [String] View to render 94 | # @param [Object] Datas to compile in the view 95 | # 96 | ## 97 | view: (template, datas) -> 98 | 99 | view = new View() 100 | 101 | return view.render template, datas 102 | 103 | module.exports = Controller 104 | -------------------------------------------------------------------------------- /core/view.coffee: -------------------------------------------------------------------------------- 1 | ## 2 | # View 3 | # 4 | # Micro-Facade for Handlebars. 5 | ## 6 | class View 7 | 8 | ## 9 | # Constructor 10 | # 11 | # The constructor 12 | # 13 | ## 14 | constructor: -> 15 | 16 | ## 17 | # Render 18 | # 19 | # Render a template 20 | # 21 | # @param [String] Template to compile 22 | # @param [Object] Datas to compile with the template 23 | # 24 | ## 25 | render: (template, datas) -> 26 | 27 | template = template.split('.').join('/') 28 | 29 | template = require 'views/' + template 30 | 31 | return template(datas) 32 | 33 | module.exports = View 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gotham-framework", 3 | "description": "Coffeescript Framework for lazy Frontend developers", 4 | "author": "Ges Jeremie", 5 | "version": "0.0.1", 6 | "repository": { 7 | "type": "git", 8 | "url": "" 9 | }, 10 | "scripts": { 11 | "test": "brunch test" 12 | }, 13 | "dependencies": { 14 | "auto-reload-brunch": ">= 1.0 < 1.8", 15 | "clean-css-brunch": ">= 1.0 < 1.8", 16 | "coffee-script-brunch": "^1.8.1", 17 | "css-brunch": ">= 1.0 < 1.8", 18 | "eco-brunch": "^1.7.5", 19 | "javascript-brunch": ">= 1.0 < 1.8", 20 | "sass-brunch": "^1.8.8", 21 | "uglify-js-brunch": ">= 1.0 < 1.8" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gothamjs/framework/92fd1e1bcd291c0c51033fc7923f021c74beaf95/vendor/.gitkeep --------------------------------------------------------------------------------