Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
- Transferred ownership of this repo to the Roosevelt framework.
- Dropped bower support, replaced it with npm distribution.
- Added webpack bundling.
- Removed `expressAppName` param.
- Refactored code.
- Rewrote sample app to reflect the overhaul.
- Overhauled README to reflect the overhaul.
- Added CHANGELOG and CONTRIBUTING docs.
  • Loading branch information
kethinov committed Jun 14, 2021
1 parent 449546b commit d1a2c40
Show file tree
Hide file tree
Showing 15 changed files with 7,841 additions and 226 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

164 changes: 157 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,177 @@
### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# rollup.js default build output
dist/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# Storybook build outputs
.out
.storybook-out

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Temporary folders
tmp/
temp/

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

bower_components
# Sample app build artifacts
sampleApp/build
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

## Next version

- Put your changes here...

## 2.0.0

- Transferred ownership of this repo to the Roosevelt framework.
- Dropped bower support, replaced it with npm distribution.
- Added webpack bundling.
- Removed `expressAppName` param.
- Refactored code.
- Rewrote sample app to reflect the overhaul.
- Overhauled README to reflect the overhaul.
- Added CHANGELOG and CONTRIBUTING docs.

## 1.0.6

- Removed moot bower version.

## 1.0.5

- Removed hard dependency: Having this dependency explicitly declared caused page.js to get downloaded twice potentially and also made it harder for users to control which version of page.js they prefer.

## 1.0.4

- Fixed bower ignore issue.

## 1.0.3

- page.js 1.5 support and browserify support.

## 1.0.2

- page.js 1.4.0 compatibility.

## 1.0.1

- Removing redundant code.

## 1.0.0

- Initial version.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# How to contribute

## Before opening a pull request

- Be sure all tests pass: `npm t`.
- Ensure 100% code coverage and write new tests if necessary: `npm run coverage`.
- Add your changes to `CHANGELOG.md`.

## Release process

If you are a maintainer of this module, please follow the following release procedure:

- Merge all desired pull requests into master.
- Bump `package.json` to a new version and run `npm i` to generate a new `package-lock.json`.
- Alter CHANGELOG "Next version" section and stamp it with the new version.
- Paste contents of CHANGELOG into new version commit.
- Open and merge a pull request with those changes.
- Tag the merge commit as the a new release version number.
- Publish commit to npm.
3 changes: 2 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
License
===

All original code in this library is licensed under the [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0)</a>. Commercial and noncommercial use is permitted with attribution.
All original code in this project is licensed under the [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). Commercial and noncommercial use is permitted with attribution.

71 changes: 17 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
page.js-express-mapper.js
page-express-mapper
===

A plugin for [page.js](http://visionmedia.github.io/page.js/) which aims to provide a direct imitation of the [Express](http://expressjs.com/) API so you can write isomorphic/universal controller code that can be shared on the client and the server with your Express application without modification.
[![npm](https://img.shields.io/npm/v/page-express-validator.svg)](https://www.npmjs.com/package/page-express-validator)

With this plugin you should be able to write isomorphic/universal JavaScript apps that share the same models, views, and controllers on the client and the server, so long as you run Express on the server, page.js on the client, and use a JS templating system that can run on the client and server.
A plugin for [page.js](http://visionmedia.github.io/page.js/) which aims to provide a direct imitation of the [Express](http://expressjs.com/) API so you can write isomorphic/universal router code that can be shared on the client and the server with your Express application without modification.

Installation
===

Either download the file from here or use [bower](http://bower.io/):
With this plugin you should be able to write isomorphic/universal JavaScript apps that maximize code reuse on the client and the server, so long as you run Express on the server, page.js on the client, and use a JS-based templating system that can run on the client and server.

```
bower install page.js-express-mapper.js
```
This module was built and is maintained by the [Roosevelt web framework](https://github.com/rooseveltframework/roosevelt) [team](https://github.com/orgs/rooseveltframework/people), but it can be used independently of Roosevelt as well.

Initialization
Usage
===

Load `page.js-express-mapper.js` after loading `page.js`.

Then initialize it by calling `pageExpressMapper()` *before* defining any routes.
- Add `page-express-validator` to your npm dependencies.
- Load `page-express-mapper.js` into your frontend JS bundle along with `page.js`.
- Then initialize it by calling `pageExpressMapper()` *before* defining any routes.

Params
===
Expand All @@ -35,7 +30,7 @@ This is designed to mimic the [Express render method](http://expressjs.com/api.h

As with Express, the `template` argument should refer to a named template and the `model` argument should be a JSON string or JavaScript object.

For example, using the [Teddy](https://github.com/kethinov/teddy) templating engine:
For example, using the [Teddy](https://github.com/rooseveltframework/teddy) templating engine:

```js
pageExpressMapper({
Expand All @@ -48,17 +43,6 @@ pageExpressMapper({

This should work with any templating engine which supports both client-side rendering and Express on the server-side.

string expressAppName
---

*Optional*

In the Express API, routes are defined as [children of a named app object](http://expressjs.com/api.html#app.route).

As such, to directly imitate Express client-side, this plugin defines a global variable named for your Express app just as is done in Node.js.

Default: `'app'`

object customRouter
---

Expand Down Expand Up @@ -88,11 +72,10 @@ Default: `undefined`
Tying it all together
===


Assuming your server code begins as:

```js
var app = express();
const app = express()
```

And your client code begins as something like:
Expand All @@ -104,8 +87,7 @@ pageExpressMapper({
* your favorite templating
* system here
*/
},
expressAppName: 'app'
}
});
```

Expand All @@ -120,27 +102,8 @@ app.route('/someRoute').get(function(req, res) {
Sample app
===

Check out `sampleApp.html` for simple demonstration of how this works.

To run it, follow these steps:

Clone this repo:

```
git clone https://github.com/kethinov/page.js-express-mapper.js.git
```

Install page.js:

```
cd page.js-express-mapper.js
bower install page.js
```

Start a simple web server (example assumes you have python installed, but you could use any web server):

```
python -m SimpleHTTPServer
```

Then open [http://localhost:8000/sampleApp.html](http://localhost:8000/) in your browser.
- Clone this repo.
- Install dependencies.
- `cd` to your clone.
- `npm run sample-app`.
- Open the browser dev tools and examine the console logs when you click the links in the sample app to see evidence of it working.
Loading

0 comments on commit d1a2c40

Please sign in to comment.