├── Views ├── _ViewStart.cshtml ├── Home │ └── Index.cshtml ├── Shared │ └── _Layout.cshtml └── web.config ├── Global.asax ├── Scripts └── App │ ├── main.js │ └── Components │ ├── UserPanel.jsx │ ├── ElapsedTime.jsx │ └── Todo.jsx ├── reactServerConfig.json ├── Controllers └── HomeController.cs ├── Content ├── styles.css.map ├── styles.css └── styles.less ├── App_Start ├── RouteConfig.cs ├── WebApiConfig.cs ├── ReactConfig.cs └── BundleConfig.cs ├── package.json ├── Global.asax.cs ├── ReactDotNetBrowserify.sln ├── Web.Release.config ├── Web.Debug.config ├── Properties └── AssemblyInfo.cs ├── packages.config ├── .gitignore ├── README.md ├── gulpfile.js ├── Web.config ├── ReactDotNetBrowserify.csproj └── LICENSE /Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ReactDotNetBrowserify.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Scripts/App/main.js: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function () { 2 | console.log('Hi, I\'m client script!'); 3 | }); 4 | 5 | -------------------------------------------------------------------------------- /reactServerConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "expose": [ 3 | { "path": "./Scripts/App/Components/Todo", "name" : "Todo" }, 4 | { "path": "./Scripts/App/Components/UserPanel", "name" : "UserPanel" } 5 | ] 6 | } -------------------------------------------------------------------------------- /Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace ReactDotNetBrowserify.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | ViewBag.Title = "ReactJS.NET + Browserify"; 14 | ViewBag.UserName = "Guest"; 15 | return View(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Scripts/App/Components/UserPanel.jsx: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var ElapsedTime = require('./ElapsedTime'); 3 | 4 | var UserPanel = React.createClass({ 5 | render: function() { 6 | return ( 7 |
8 |
Hello {this.props.name}!
9 | Log out 10 |
Logged in
11 |
12 | ); 13 | } 14 | }); 15 | module.exports = UserPanel; 16 | -------------------------------------------------------------------------------- /Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 |
2 | @{ 3 | var props = new 4 | { 5 | entries = new[] { 6 | new {Text = "Make to do list", CreatedAt = DateTime.Now - TimeSpan.FromDays(35) }, 7 | new {Text = "Check off first thing on to do list ", CreatedAt = DateTime.Now - TimeSpan.FromDays(13) }, 8 | new {Text = "Realize you've already accomplished 2 things", CreatedAt = DateTime.Now - TimeSpan.FromDays(5) } 9 | } 10 | }; 11 | } 12 | @Html.React("Todo", props) 13 |
14 | -------------------------------------------------------------------------------- /Content/styles.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"styles.css","sources":["styles.less"],"names":[],"mappings":"AAAA;EACE,yCAAA;EACA,eAAA;;AAGF;EACE,YAAA;EACA,mBAAA;EACA,iCAAA;;AAHF,IAKE;EACE,WAAA;EACA,qBAAA;EACA,cAAA;EACA,cAAA;;AATJ,IAYE;EAEE,gBAAA;EACA,aAAA;EACA,YAAA;EACA,qBAAA;EACA,YAAA;;AAlBJ,IAYE,YAQE,EAAC;EACC,qBAAA;EACA,YAAA;EACA,kBAAA;EACA,WAAA;;AAxBN,IAYE,YAeE,IAAG;EACD,qBAAA;EACA,WAAA;;AA7BN,IAYE,YAoBE;EACE,gBAAA;EACA,cAAA;EACA,WAAA;EACA,YAAA;;AAKN;EACE,YAAA;EACA,qBAAA;EACA,kBAAA;EAaA,mBAAA;EACA,wBAAA;;AAjBF,KAKE;EAAI,SAAA;EAAW,UAAA;;AALjB,KAOE;EACE,UAAA;EACA,qBAAA;;AATJ,KAOE,GAGE;EACE,6BAAA;EACA,eAAA;;AAZN,KAkBE;EACM,gBAAA;;AAnBR,KAsBE;EACC,gBAAA;EACA,cAAA"} -------------------------------------------------------------------------------- /App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace ReactDotNetBrowserify 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactdotnet-browserify", 3 | "version": "0.0.1", 4 | "private": true, 5 | "dependencies": { 6 | "markdown": "~0.5.0", 7 | "moment": "~2.7.0", 8 | "react": "^0.13.3" 9 | }, 10 | "devDependencies": { 11 | "browserify": "~6.0.3", 12 | "combined-stream": "^1.0.5", 13 | "gulp": "~3.8.10", 14 | "gulp-plumber": "~0.6.6", 15 | "gulp-watch": "~0.6.10", 16 | "memory-streams": "0.0.3", 17 | "reactify": "~1.1.1", 18 | "vinyl-source-stream": "~1.0.0" 19 | }, 20 | "browserify": { 21 | "transform": [ 22 | [ 23 | "reactify", 24 | { 25 | "es6": true 26 | } 27 | ] 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace ReactDotNetBrowserify 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | // Web API configuration and services 13 | 14 | // Web API routes 15 | config.MapHttpAttributeRoutes(); 16 | 17 | config.Routes.MapHttpRoute( 18 | name: "DefaultApi", 19 | routeTemplate: "api/{controller}/{id}", 20 | defaults: new { id = RouteParameter.Optional } 21 | ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /App_Start/ReactConfig.cs: -------------------------------------------------------------------------------- 1 | using React; 2 | 3 | [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(ReactDotNetBrowserify.ReactConfig), "Configure")] 4 | 5 | namespace ReactDotNetBrowserify 6 | { 7 | public static class ReactConfig 8 | { 9 | public static void Configure() 10 | { 11 | ReactSiteConfiguration.Configuration = new ReactSiteConfiguration(); 12 | 13 | // If you want to use server-side rendering of React components, 14 | // add all the necessary JavaScript files here. This includes 15 | // your components as well as all of their dependencies. 16 | // See http://reactjs.net/ for more information. 17 | 18 | // Example: 19 | ReactSiteConfiguration.Configuration 20 | .AddScript("~/Scripts/dist/serverBundle.js"); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | using System.Web.Security; 8 | using System.Web.SessionState; 9 | using System.Web.Http; 10 | using System.Web.Optimization; 11 | 12 | namespace ReactDotNetBrowserify 13 | { 14 | public class Global : HttpApplication 15 | { 16 | void Application_Start(object sender, EventArgs e) 17 | { 18 | // Code that runs on application startup 19 | AreaRegistration.RegisterAllAreas(); 20 | GlobalConfiguration.Configure(WebApiConfig.Register); 21 | RouteConfig.RegisterRoutes(RouteTable.Routes); 22 | BundleConfig.RegisterBundles(BundleTable.Bundles); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Optimization 2 | 3 | 4 | 5 | 6 | 7 | @ViewBag.Title - My ASP.NET Application 8 | 9 | 10 | 11 | 21 |
22 | @RenderBody() 23 |
24 | @Scripts.Render("~/bundles/main") 25 | @Html.ReactInitJavaScript() 26 | 27 | -------------------------------------------------------------------------------- /Scripts/App/Components/ElapsedTime.jsx: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var moment= require('moment'); 3 | 4 | var ElapsedTime = React.createClass({ 5 | getInitialState: function () { 6 | return {secondsElapsed: 0}; 7 | }, 8 | componentDidMount: function () { 9 | this.interval = setInterval(this.tick, 1000); 10 | }, 11 | componentWillUnmount: function () { 12 | clearInterval(this.interval); 13 | }, 14 | tick: function () { 15 | if (this.state.secondsElapsed >= 59) { 16 | clearInterval(this.interval); 17 | this.interval = setInterval(this.tick, 60000); 18 | } 19 | this.setState({secondsElapsed: moment().diff(moment(this.props.since), 'seconds')}); 20 | }, 21 | render: function () { 22 | return ( 23 | {moment(this.props.since).fromNow()} 24 | ); 25 | } 26 | }); 27 | 28 | 29 | module.exports = ElapsedTime; -------------------------------------------------------------------------------- /App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | using System.Web.Optimization; 11 | using System.Web.Optimization.React; 12 | 13 | namespace ReactDotNetBrowserify 14 | { 15 | public static class BundleConfig 16 | { 17 | // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 18 | public static void RegisterBundles(BundleCollection bundles) 19 | { 20 | bundles.Add(new Bundle("~/bundles/main").Include( 21 | "~/Scripts/dist/clientBundle.js" 22 | )); 23 | 24 | // Force minification/combination even in debug mode 25 | BundleTable.EnableOptimizations = false; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /ReactDotNetBrowserify.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Web 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactDotNetBrowserify", "ReactDotNetBrowserify.csproj", "{9B8448CF-93BB-41C6-9BFB-F30FD9FDB948}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9B8448CF-93BB-41C6-9BFB-F30FD9FDB948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9B8448CF-93BB-41C6-9BFB-F30FD9FDB948}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9B8448CF-93BB-41C6-9BFB-F30FD9FDB948}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9B8448CF-93BB-41C6-9BFB-F30FD9FDB948}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Content/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Helvetica, Arial, Sans-Serif; 3 | font-size: 100%; 4 | } 5 | #nav { 6 | height: 50px; 7 | background: #EEE9E9; 8 | border-bottom: 1px dashed #000000; 9 | } 10 | #nav .title { 11 | float: left; 12 | display: inline-block; 13 | font-size: 2em; 14 | color: #9a6525; 15 | } 16 | #nav .user-panel { 17 | font-size: 0.9em; 18 | padding: 10px; 19 | width: 170px; 20 | display: inline-block; 21 | float: right; 22 | } 23 | #nav .user-panel a.logout { 24 | display: inline-block; 25 | float: right; 26 | padding-left: 30px; 27 | color: #000; 28 | } 29 | #nav .user-panel div.greeting { 30 | display: inline-block; 31 | float: left; 32 | } 33 | #nav .user-panel .elapsed { 34 | font-size: 0.7em; 35 | color: #5163d0; 36 | clear: both; 37 | float: right; 38 | } 39 | .todo { 40 | width: 400px; 41 | margin: 30px 0 0 10px; 42 | padding-left: 10px; 43 | background: #EEE9E9; 44 | border: 1px dashed black; 45 | } 46 | .todo p { 47 | margin: 0; 48 | padding: 0; 49 | } 50 | .todo ul { 51 | padding: 0; 52 | list-style-type: none; 53 | } 54 | .todo ul li { 55 | border-bottom: 1px dashed red; 56 | margin-top: 5px; 57 | } 58 | .todo .hint { 59 | font-size: 0.7em; 60 | } 61 | .todo .elapsed { 62 | font-size: 0.7em; 63 | color: #5163d0; 64 | } 65 | /*# sourceMappingURL=styles.css.map */ -------------------------------------------------------------------------------- /Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 20 | 21 | 32 | 33 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ReactDotNetBrowserify")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ReactDotNetBrowserify")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e02d94d2-b4e2-44a3-b09f-8ce384fee4f0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Content/styles.less: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Helvetica, Arial, Sans-Serif; 3 | font-size: 100%; 4 | } 5 | 6 | #nav { 7 | height: 50px; 8 | background: #EEE9E9; 9 | border-bottom: 1px dashed #000000; 10 | 11 | .title { 12 | float: left; 13 | display: inline-block; 14 | font-size: 2em; 15 | color: #9a6525; 16 | } 17 | 18 | .user-panel { 19 | float: right; 20 | font-size: 0.9em; 21 | padding: 10px; 22 | width: 170px; 23 | display: inline-block; 24 | float: right; 25 | 26 | a.logout { 27 | display: inline-block; 28 | float: right; 29 | padding-left: 30px; 30 | color: #000; 31 | } 32 | 33 | div.greeting { 34 | display: inline-block; 35 | float: left; 36 | } 37 | 38 | .elapsed { 39 | font-size: 0.7em; 40 | color: #5163d0; 41 | clear: both; 42 | float: right; 43 | } 44 | } 45 | } 46 | 47 | .todo { 48 | width: 400px; 49 | margin: 30px 0 0 10px; 50 | padding-left: 10px; 51 | 52 | p { margin: 0; padding: 0; } 53 | 54 | ul { 55 | padding: 0; 56 | list-style-type: none; 57 | li { 58 | border-bottom: 1px dashed red; 59 | margin-top: 5px; 60 | } 61 | } 62 | 63 | background: #EEE9E9; 64 | border: 1px dashed black; 65 | .hint { 66 | font-size: 0.7em; 67 | } 68 | 69 | .elapsed { 70 | font-size: 0.7em; 71 | color: #5163d0; 72 | } 73 | } 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Views/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Scripts/App/Components/Todo.jsx: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var markdown = require('markdown').markdown; 3 | var ElapsedTime = require('./ElapsedTime'); 4 | 5 | var TodoItem = React.createClass({ 6 | render: function() { 7 | return
  • 8 |
    9 |
    Added
    10 |
  • ; 11 | } 12 | }); 13 | 14 | var TodoList = React.createClass({ 15 | render: function() { 16 | var createItem = function(item, index) { 17 | return ; 18 | }; 19 | return
      {this.props.items.map(createItem)}
    ; 20 | } 21 | }); 22 | var TodoApp = React.createClass({ 23 | getInitialState: function() { 24 | var items = this.props.entries ? this.props.entries.slice(0) : []; 25 | return {items: items, text: ''}; 26 | }, 27 | onChange: function(e) { 28 | this.setState({text: e.target.value}); 29 | }, 30 | handleSubmit: function(e) { 31 | e.preventDefault(); 32 | if(this.state.text.length > 0) { 33 | var nextItems = this.state.items.concat([{Text: this.state.text, CreatedAt: (new Date).toJSON()}]); 34 | var nextText = ''; 35 | this.setState({items: nextItems, text: nextText}); 36 | } 37 | }, 38 | render: function() { 39 | return ( 40 |
    41 |

    your todos:

    42 | 43 |
    44 | 45 | 46 |
    *supports Markdown syntax
    47 |
    48 |
    49 | ); 50 | } 51 | }); 52 | 53 | module.exports = TodoApp; -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # .gitignore for ASP.NET MVC / Windows Azure development 2 | # Original file: https://gist.github.com/3318347 by @codingoutloud 3 | ## Github doc on ignoring files: https://help.github.com/articles/ignoring-files 4 | ## The man page for .gitignore (referenced by github): http://man.cx/gitignore 5 | ## Of possible interest (can be complex): https://github.com/github/gitignore 6 | 7 | # Troubleshooting 8 | # 1. If you add a .gitignore file to an existing repo (or significantly change one), you may want 9 | # to force it to act as though the new/updated .gitignore was in force the whole time. 10 | ## http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring 11 | ### git rm -r --cached . 12 | ### git add . 13 | ### git commit -m ".gitignore is now working" 14 | # 2. If you get an Unsynchronized Commit error in the GitHub Windows client, you may want to try this. 15 | ## http://stackoverflow.com/questions/8174324/github-unsynchronized-commit 16 | # 3. If you get "unstaged changes" "you cannot sync with unstaged changes" "please commit your changes and try again" from 17 | # Github for Windows client... 18 | ## ? 19 | 20 | # don't ignore myself! 21 | !.gitignore 22 | 23 | # Visual Studio build objects 24 | bin/ 25 | csx/ 26 | obj/ 27 | rcf/ 28 | 29 | # Windows Azure Publish Settings contain security keys for accessing your Windows Azure account 30 | .publishsettings 31 | 32 | # Visual Studio user-specific files 33 | ## Useful whenever working as part of a team or on software (like open source) that others will download 34 | *.suo 35 | *.user 36 | 37 | # Access Control Service integration (via FedUtil or Add STS Reference from VS2010) will create FederationMetadata.xml below this folder 38 | ##=> looks like FederationMetadata.xml is referenced in csproj, so need it in source control 39 | # FederationMetadata\ 40 | ## Multiple applications of FedUtil will result in *.backup.1, *.backup.2, etc., files for Web.config and FederationMetadata.xml 41 | *.backup.* 42 | 43 | # NuGet 44 | # Also consider letting NuGet automatically restore missing packages for you: 45 | ## http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages/ 46 | packages/ 47 | 48 | # ReSharper 49 | _ReSharper*/ 50 | 51 | # NCrunch 52 | *ncrunch* 53 | 54 | #Webstorm IDE files 55 | .idea/ 56 | 57 | 58 | node_modules/ 59 | Scripts/Build/ 60 | Scripts/dist/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Information 2 | 3 | A sample of how to use [ASP.NET MVC + React.js integration](http://reactjs.net/) together with [Browserify bundles](http://browserify.org/) and take advantage of both technologies. 4 | 5 | ## Goals 6 | 7 | * Script and content packages are managed by [npm](https://www.npmjs.org/); 8 | * JavaScript is written modular way, Node.js style; 9 | * Build tasks for scripts and content are configured in [Gulp.js](http://gulpjs.com/) build system 10 | * When [rendering React components on the server-side](http://reactjs.net/guides/server-side-rendering.html), list only the relevant components, **without having to list their dependencies**. Dependency resolution relies on the npm module resolution algorithm implemented in Browserify. 11 | 12 | 13 | ## Requirements 14 | 15 | In order to build project you'll need to have installed: 16 | 17 | * Visual Studio (project was created in VS2013 Web Express) 18 | * Node.js 19 | * npm 20 | * Install Gulp.js tool by running ```npm install –g gulp``` 21 | 22 | ## Quick Start 23 | 24 | * Install referenced npm packages: ``` npm install ``` 25 | * Build and run ASP.NET MVC project in Visual Studio 26 | * initial build will automatically install referenced NuGet packages 27 | 28 | 29 | ## Usage 30 | 31 | If pre-rendering some React components server-side, configure them in [reactServerConfig.json](./reactServerConfig.json): 32 | 33 | Example: 34 | 35 | ```javascript 36 | { 37 | "expose": [ 38 | { "path": "./Scripts/App/Components/Todo", "name" : "Todo" }, 39 | { "path": "./Scripts/App/Components/HelloWorld", "name" : "HelloWorld" } 40 | ] 41 | } 42 | ``` 43 | 44 | This configuration is processed by the build task to create a special Browserify bundle for the server (See [gulpfile.js](./gulpfile.js)). ReactJS.NET [ReactConfig](./App_Start/ReactConfig.cs) only needs to reference this one bundle file. 45 | 46 | ASP.NET project is configured to trigger the bundling automatically (running gulp task in pre-build event of .NET project). 47 | 48 | Additionally, there is a default gulp task to automatically rebuild client-side assets on every change of source scripts; Run the ```gulp``` in command-line to start watching for changes; 49 | 50 | More detailed informations can be found in [blog article](http://janekk.github.io/tech/2014/07/25/aspnet-mvc-reactjs-browserify.html). 51 | 52 | ## TODO 53 | ... 54 | 55 | 56 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | 3 | var paths = { 4 | src: { 5 | jsx: 'Scripts/App/Components/*.jsx', 6 | app: './Scripts/App/main.js', 7 | scripts: 'Scripts/**/*.js' 8 | }, 9 | dest: { 10 | bundles: 'Scripts/dist', 11 | bundlesFilter: '!Scripts/dist/**/*.js', 12 | serverBundle: 'serverBundle.js', 13 | clientBundle: 'clientBundle.js', 14 | jsx: 'Scripts/App/Components' 15 | } 16 | }; 17 | 18 | var source = require('vinyl-source-stream'); 19 | var streams = require('memory-streams'); 20 | var CombinedStream = require('combined-stream'); 21 | var os = require('os'); 22 | var createServerBundle = function (browserify, configPath) { 23 | var utils = { 24 | parseConfig : function(config) { 25 | if (config) { 26 | if (config.expose) { 27 | var components = {}; 28 | //1. parse the configuration 29 | config.expose.forEach(function (component) { 30 | var path, name; 31 | 32 | if (typeof component === 'string') { 33 | path = component; 34 | } 35 | else { 36 | path = component.path; 37 | if (component.name) { 38 | name = component.name; 39 | } 40 | } 41 | if (name === undefined) { 42 | var splitted = path.split('/'); 43 | name = splitted[splitted.length - 1]; 44 | } 45 | components[name] = path; 46 | }); 47 | return components; 48 | } 49 | } 50 | }, 51 | exposeReact: function(exposedVariables, requires) { 52 | requires.push({ file: "react" }); 53 | exposedVariables.append('var React = require("react");' + os.EOL); 54 | } 55 | }; 56 | 57 | if (configPath === undefined) { 58 | configPath = './reactServerConfig.json'; 59 | } 60 | var config = require(configPath); 61 | 62 | var serverComponents = utils.parseConfig(config); 63 | if (serverComponents) { 64 | var exposedVariables = CombinedStream.create(); 65 | var requires = []; 66 | exposedVariables.append(';' + os.EOL); 67 | utils.exposeReact(exposedVariables, requires); 68 | 69 | for (var name in serverComponents) { 70 | var path = serverComponents[name]; 71 | requires.push({file: path, expose: name}); 72 | exposedVariables.append('var ' + name + ' = require("' + name + '");'); 73 | } 74 | browserify.require(requires); 75 | var bundleStream = CombinedStream.create(); 76 | bundleStream.append(browserify.bundle()); 77 | bundleStream.append(exposedVariables); 78 | 79 | return bundleStream; 80 | } 81 | }; 82 | 83 | var browserify = require('browserify'); 84 | var gulpServerBundle = function () { 85 | var bundle = createServerBundle(browserify( 86 | { 87 | extensions: ['.jsx', '.js'] 88 | } 89 | )); 90 | return bundle 91 | .pipe(source(paths.dest.serverBundle)) 92 | .pipe(gulp.dest(paths.dest.bundles)); 93 | }; 94 | 95 | gulp.task('server-build', function () { 96 | return gulpServerBundle(); 97 | }); 98 | 99 | var gulpClientBundle = function () { 100 | var b = browserify(paths.src.app, 101 | { 102 | extensions: ['.jsx', '.js'] 103 | }); 104 | var bundle = createServerBundle(b); 105 | return bundle 106 | .pipe(source(paths.dest.clientBundle)) 107 | .pipe(gulp.dest(paths.dest.bundles)); 108 | }; 109 | 110 | gulp.task('client-build', function () { 111 | return gulpClientBundle(); 112 | }); 113 | 114 | var watch = require('gulp-watch'); 115 | gulp.task('watch', function () { 116 | watch({glob: paths.src.jsx}, function (files) { 117 | return files.pipe(react()) 118 | .pipe(gulp.dest(paths.dest.jsx)); 119 | }); 120 | 121 | watch({glob: [paths.src.scripts, paths.dest.bundlesFilter]}, function () { 122 | return gulpClientBundle(); 123 | }); 124 | }); 125 | 126 | gulp.task('default', ['watch']); 127 | 128 | -------------------------------------------------------------------------------- /Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 |
    10 |
    11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /ReactDotNetBrowserify.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {9B8448CF-93BB-41C6-9BFB-F30FD9FDB948} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | ReactDotNetBrowserify 15 | ReactDotNetBrowserify 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | true 25 | full 26 | false 27 | bin\ 28 | DEBUG;TRACE 29 | prompt 30 | 4 31 | 32 | 33 | pdbonly 34 | true 35 | bin\ 36 | TRACE 37 | prompt 38 | 4 39 | 40 | 41 | 42 | False 43 | packages\AjaxMin.5.11.5295.12309\lib\net40\AjaxMin.dll 44 | 45 | 46 | False 47 | packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll 48 | 49 | 50 | packages\Cassette.2.4.2\lib\net40-client\Cassette.dll 51 | 52 | 53 | False 54 | packages\Cassette.React.1.1.3\lib\net40\Cassette.React.dll 55 | 56 | 57 | packages\JavaScriptEngineSwitcher.V8.1.2.1\lib\net40\ClearScript.dll 58 | 59 | 60 | False 61 | packages\JavaScriptEngineSwitcher.Core.1.2.0\lib\net40\JavaScriptEngineSwitcher.Core.dll 62 | 63 | 64 | False 65 | packages\JavaScriptEngineSwitcher.Jint.1.2.1\lib\net40\JavaScriptEngineSwitcher.Jint.dll 66 | 67 | 68 | False 69 | packages\JavaScriptEngineSwitcher.Msie.1.2.0\lib\net40\JavaScriptEngineSwitcher.Msie.dll 70 | 71 | 72 | packages\JavaScriptEngineSwitcher.V8.1.2.1\lib\net40\JavaScriptEngineSwitcher.V8.dll 73 | 74 | 75 | False 76 | packages\JavaScriptEngineSwitcher.Jint.1.2.1\lib\net40\Jint.dll 77 | 78 | 79 | 80 | True 81 | packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 82 | 83 | 84 | False 85 | packages\MsieJavaScriptEngine.1.5.0\lib\net40\MsieJavaScriptEngine.dll 86 | 87 | 88 | False 89 | packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll 90 | 91 | 92 | False 93 | packages\React.Core.1.1.3\lib\net40\React.dll 94 | 95 | 96 | packages\React.JavaScriptEngine.ClearScriptV8.1.1.3\lib\net40\React.JavaScriptEngine.ClearScriptV8.dll 97 | 98 | 99 | False 100 | packages\React.Web.1.1.3\lib\net40\React.Web.dll 101 | 102 | 103 | False 104 | packages\React.Web.Mvc4.1.1.3\lib\net40\React.Web.Mvc4.dll 105 | 106 | 107 | 108 | False 109 | packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | False 122 | packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll 123 | 124 | 125 | False 126 | packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll 127 | 128 | 129 | False 130 | packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll 131 | 132 | 133 | False 134 | packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll 135 | 136 | 137 | packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 138 | 139 | 140 | False 141 | packages\System.Web.Optimization.React.1.1.3\lib\net40\System.Web.Optimization.React.dll 142 | 143 | 144 | False 145 | packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll 146 | 147 | 148 | False 149 | packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll 150 | 151 | 152 | False 153 | packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll 154 | 155 | 156 | False 157 | packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | packages\WebActivatorEx.2.0.5\lib\net40\WebActivatorEx.dll 168 | 169 | 170 | False 171 | packages\WebGrease.1.6.0\lib\WebGrease.dll 172 | 173 | 174 | 175 | 176 | 177 | 178 | PreserveNewest 179 | 180 | 181 | PreserveNewest 182 | 183 | 184 | PreserveNewest 185 | 186 | 187 | PreserveNewest 188 | 189 | 190 | styles.less 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | Global.asax 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | Designer 214 | 215 | 216 | 217 | 218 | 219 | styles.css 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | Web.config 228 | 229 | 230 | Web.config 231 | 232 | 233 | 234 | 235 | 236 | 237 | 10.0 238 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | True 248 | True 249 | 54482 250 | / 251 | http://localhost:54483/ 252 | False 253 | False 254 | 255 | 256 | False 257 | 258 | 259 | 260 | 261 | 262 | 263 | cd $(ProjectDir) 264 | gulp server-build 265 | 266 | 267 | 273 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. --------------------------------------------------------------------------------