彭博的Brisket JavaScript應用程序框架:Brisket

jopen 9年前發布 | 12K 次閱讀 Brisket JavaScript開發

Brisket是一個用于使用isomorphic JavaScript來構建單頁Web應用的框架。一個Brisket應用程序既是一個傳統的網站,同時也是一個單頁Web應用程序。Brisket提供的工具讓你只需要發時間專注你應用程序的邏輯,而不用擔心代碼的運行環境。

Getting Started

Using generator-brisket is the fastest way to get started.

Install Yeoman:

npm install -g yo

To install generator-brisket from npm, run:

npm install -g generator-brisket

Create a directory for your app:

mkdir projectname cd projectname

Finally, initiate the generator and run your app:

yo brisket && grunt

Your first brisket app will be available at http://localhost:8080

Getting More Started

Now that you have a working app, check out our Recipes for common use cases.

Documentation

Brisket's Parts

  • Brisket.createServer: A function that returns an express engine that you can use in your application to run the server.
  • Brisket.Routers: A helper object to help you initialize Backbone Routers.
  • Brisket.ServerApp: An application that will do the necessary wiring on the server. Inherit to add your own functionality.
  • Brisket.ClientApp: An application that will do the necessary wiring on the client. Inherit to add your own functionality.
  • Brisket.RouterBrewery: Brews routers that know how to route on the server and the client. Allows you to make your own RouterBrewery.
  • Brisket.Controller: A helper object to move functionality off of the router (it doesn't provide any functionality; just semantics).
  • Brisket.Model: Our version of a Backbone.Model that knows how to sync on the server and the client.
  • Brisket.Collection: Our version of a Backbone.Collection that knows how to sync on the server and the client.
  • Brisket.View: Our version of a Backbone.View that allows support for some of the core features - reattaching views, child view management, memory management, etc.
  • Brisket.Layout: A specialized View that handles meta tags, page title, etc.
  • Brisket.Layout.Metatags: Use this class to make metatags for "pages".
  • Brisket.Templating.TemplateAdapter: Inherit from this to tell Brisket how to render templates.
  • Brisket.Templating.StringTemplateAdapter: The default template adapter. Set a View's template key to be a string template to get started.
  • Brisket.ErrorViewMapping: Creates errorViewMappings for your routers (e.g. 404 should show Page Not Found).
  • Brisket.version: The version of Brisket. On the client, the version can be accessed bywindow.Brisket.versionafter the ClientApp has started.
  • Brisket.onError: Registers error callback.

Brisket Concepts And High Level Systems

Using Brisket in your project

Install the Brisket into your project:

npm install brisket --save

Bundling your Brisket application

Check the Bundling With Browserify Recipe!

Compatibility and Requirements

Brisket also depends on the following libraries:

  • jQuery ~1.11.1
  • jsdom ~0.11.1
  • Underscore ~1.6.0
  • Backbone ~1.1.2
  • bluebird ~2.2.1
  • jquery-mockjax ~1.5.3
  • express ~4.0.0
  • qs 1.2.2

Browser Support

Chrome, Firefox, Safari, iOS 6+, Android 4+, Internet Explorer 9+

For support in older versions of IE you can include your favorite shim libraries in the head of your layout. For example to support IE8 include the following in your head tag:

<!--[if lt IE 9]>
    <script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.min.js'></script>
    <script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-sham.min.js'></script>
<![endif]-->

To support IE7, include the snippet above AND the following:

<!--[if lt IE 8]>
    <script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/json3/3.3.1/json3.min.js'></script>
<![endif]-->

Note: In IEs < 10, the single page app functionality that Brisket provides will not work since pushState is not available. Brisket does not support hash tag SPA's (TODO: link this to a page describing why not). When the SPA functionality is disabled, Brisket will operate like a standard website i.e. clicking application links will cause a page reload.

Development

Make sure you havegrunt-cliinstalled globally. To install:

$ npm install -g grunt-cli

Install dependencies:

$ npm install

To run the test suite:

$ grunt

項目主頁:http://www.baiduhome.net/lib/view/home/1427337886574

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!