diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8806a61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store + +.idea/ + +components/ +build/ +node_modules/ diff --git a/README.md b/README.md index 94449ac..a240608 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # www.code4.hk website for the community. Version 2. + + +component build diff --git a/component.json b/component.json new file mode 100644 index 0000000..b632931 --- /dev/null +++ b/component.json @@ -0,0 +1,21 @@ +{ + "name": "code4hk", + "description": "www.code4.hk", + "version": "0.0.1", + "keywords": [ + "shim", + "react" + ], + "scripts": [ + "index.js" + ], + "styles": [ + "index.css" + ], + "dependencies": { + "components/modernizr": "*", + "necolas/normalize.css": "^3.0.2" + }, + "locals": ["vendor/semantic"], + "paths": ["./", "../"] +} diff --git a/images/DSC_0003.JPG b/images/DSC_0003.JPG new file mode 100644 index 0000000..189b08f Binary files /dev/null and b/images/DSC_0003.JPG differ diff --git a/images/background.jpg b/images/background.jpg new file mode 100644 index 0000000..268de8e Binary files /dev/null and b/images/background.jpg differ diff --git a/images/logo-white.png b/images/logo-white.png new file mode 100644 index 0000000..23159c6 Binary files /dev/null and b/images/logo-white.png differ diff --git a/index.css b/index.css new file mode 100644 index 0000000..07a7576 --- /dev/null +++ b/index.css @@ -0,0 +1,115 @@ +/** + Color palatte chosen: http://paletton.com/palette.php?uid=3000W0kiarSaZLgeHyIllmpoAg5 +*/ +#home { + color: #303030; +} + +#home .welcome { + background-image: url('/images/background.jpg'); + background-size: cover; + padding:252px 140px; + margin-bottom: 66px; +} + +#home .sub-header { + margin-top:40px; + text-align: center; + font-size: 1.777rem; +} + +#home .header { + margin-top:40px; + text-align: center; + font-size: 2.369rem; + font-weight: 900; + letter-spacing: 1.33px; +} + +.header-logo { + max-width:5rem; +} + +#home>.propaganda { + max-width: 960px; + margin:0 auto; +} + +.propaganda .icon-container { + font-size: 3.998rem; + text-align: center; +} + +.propaganda .ui.header { + text-align: center; +} + +#vision-community .icon { + color : #de6061; +} +#vision-civichacking .icon { + color : #B0B23B; +} +#vision-opengov .icon { + color : #496194; +} + +.code4hk-header { + width:310px; +} + +.code4hk-tagline { + color: #fefefe; + letter-spacing : 1.4px; +} + +section { + background-color: #f9f9f9; +} + +#home .stripe { + background-color: #d8d8d8; + padding: 10em 0px; + border-radius: 0em; + margin: 0em; + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); +} + +#home>.manifesto { + max-width: 960px; + margin: 0 auto; +} + +.manifesto ul { + margin-bottom: 1.5rem; +} +.manifesto p { + margin-bottom:0px; +} + +#home .curators { + margin: 0 auto; + max-width: 960px; +} + +.curators img.ui.medium.image { + width : 130px; + height: 130px; + margin: 0 auto; +} + +.curators .name { + font-size: 1.333rem; + margin:15px 0px 10px 0px; + text-align: center; +} + +footer { + text-align: center; + font-style: italic; + color: #999999; + letter-spacing: 2px; + margin-top: 40px; + padding: 25px; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..a1fb31d --- /dev/null +++ b/index.html @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + code4hk logo +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..1e067c2 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "browserify": "^9.0.3", + "intl": "*", + "literalify": "^0.4.0", + "react": "^0.13.1", + "react-intl": "*" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..8cf2f7f --- /dev/null +++ b/server.js @@ -0,0 +1,103 @@ +var http = require('http'), + browserify = require('browserify'), + literalify = require('literalify'), + React = require('react'), + DOM = React.DOM, body = DOM.body, div = DOM.div, script = DOM.script, + // This is our React component, shared by server and browser thanks to browserify + App = React.createFactory(require('./App')) + + +// Just create a plain old HTTP server that responds to two endpoints ('/' and +// '/bundle.js') This would obviously work similarly with any higher level +// library (Express, etc) +http.createServer(function(req, res) { + + // If we hit the homepage, then we want to serve up some HTML - including the + // server-side rendered React component(s), as well as the script tags + // pointing to the client-side code + if (req.url == '/') { + + res.setHeader('Content-Type', 'text/html') + + // `props` represents the data to be passed in to the React component for + // rendering - just as you would pass data, or expose variables in + // templates such as Jade or Handlebars. We just use some dummy data + // here (with some potentially dangerous values for testing), but you could + // imagine this would be objects typically fetched async from a DB, + // filesystem or API, depending on the logged-in user, etc. + var props = { + items: [ + 'Item 0', + 'Item 1', + 'Item ', + 'Item ', + ] + } + + // Here we're using React to render the outer body, so we just use the + // simpler renderToStaticMarkup function, but you could use any templating + // language (or just a string) for the outer page template + var html = React.renderToStaticMarkup(body(null, + + // The actual server-side rendering of our component occurs here, and we + // pass our data in as `props`. This div is the same one that the client + // will "render" into on the browser from browser.js + div({id: 'content', dangerouslySetInnerHTML: {__html: + React.renderToString(App(props)) + }}), + + // The props should match on the client and server, so we stringify them + // on the page to be available for access by the code run in browser.js + // You could use any var name here as long as it's unique + script({dangerouslySetInnerHTML: {__html: + 'var APP_PROPS = ' + safeStringify(props) + ';' + }}), + + // We'll load React from a CDN - you don't have to do this, + // you can bundle it up or serve it locally if you like + script({src: '//fb.me/react-0.13.1.min.js'}), + + // Then the browser will fetch and run the browserified bundle consisting + // of browser.js and all its dependencies. + // We serve this from the endpoint a few lines down. + script({src: '/bundle.js'}) + )) + + // Return the page to the browser + res.end(html) + + // This endpoint is hit when the browser is requesting bundle.js from the page above + } else if (req.url == '/bundle.js') { + + res.setHeader('Content-Type', 'text/javascript') + + // Here we invoke browserify to package up browser.js and everything it requires. + // DON'T do it on the fly like this in production - it's very costly - + // either compile the bundle ahead of time, or use some smarter middleware + // (eg browserify-middleware). + // We also use literalify to transform our `require` statements for React + // so that it uses the global variable (from the CDN JS file) instead of + // bundling it up with everything else + browserify() + .add('./browser.js') + .transform(literalify.configure({react: 'window.React'})) + .bundle() + .pipe(res) + + // Return 404 for all other requests + } else { + res.statusCode = 404 + res.end() + } + +// The http server listens on port 3000 +}).listen(3000, function(err) { + if (err) throw err + console.log('Listening on 3000...') +}) + + +// A utility function to safely escape JSON for embedding in a