{"id":18937909,"url":"https://github.com/amoeba/backbone-pushstate-example","last_synced_at":"2026-05-05T02:37:30.968Z","repository":{"id":52143713,"uuid":"119154306","full_name":"amoeba/backbone-pushstate-example","owner":"amoeba","description":"An example Backbone.js application w/ path-only (no #!) URLs via PushState (and more)","archived":false,"fork":false,"pushed_at":"2022-12-07T12:34:21.000Z","size":318,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T19:17:29.912Z","etag":null,"topics":["backbone","docker","javascript","pushstate"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amoeba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-27T10:26:23.000Z","updated_at":"2023-03-10T22:21:46.000Z","dependencies_parsed_at":"2023-01-23T17:10:17.746Z","dependency_job_id":null,"html_url":"https://github.com/amoeba/backbone-pushstate-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amoeba%2Fbackbone-pushstate-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amoeba%2Fbackbone-pushstate-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amoeba%2Fbackbone-pushstate-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amoeba%2Fbackbone-pushstate-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amoeba","download_url":"https://codeload.github.com/amoeba/backbone-pushstate-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937700,"owners_count":19721484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backbone","docker","javascript","pushstate"],"created_at":"2024-11-08T12:12:50.527Z","updated_at":"2026-03-22T00:30:20.006Z","avatar_url":"https://github.com/amoeba.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backbone-pushstate-example\n\n_An example Backbone.js application w/ path-only (no #!) URLs via PushState (and more)_\n\nThis repo contains a very simple Backbone.js app based upon the following resources:\n\n- https://github.com/bouzuya/backbone-pushstate-example (for the app)\n- https://gist.github.com/andfinally/8388113 (for the Apache config required to)\n- http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/ (for the final Apache config I used)\n\nI had numerous motivations with this repo:\n\n- Demonstrate the use of Backbone.js with the `pushState()` API to support path-only URLs instead of fragment identifiers (`/#route/` becomes `/route/`)\n- Include the necessary Apache/node.js server configuration to support what's called stateless entry. This allows users to enter your Backbone app anywhere, not just at the root\n- Make use of a modern JS development toolchain\n  - [x] `package.json` for dependency management as an improvement over vendoring assets\n  - [x] Webpack for building a single bundle `./dist/bundle.js` as an improvement over using something like Require.js\n  - [x] Source maps (via Webpack) `./dist.bundle.js.map`\n  - [ ] Hot Module Reloading (TODO)\n  - [ ] ES6 (and beyond) support (TODO)\n  - [ ] Support for more advanced JS features like async/await\n\n## Stateless Entry\n\nStateless entry basically involves serving your `index.html` in front of a web server that redirects requests that don't directly point to your `index.html` to it, preserving the path and query parameters along the way.\nThis can be done with using Apache and `mod_rewrite`:\n\n```text\n\u003cIfModule mod_rewrite.c\u003e\n    RewriteEngine On\n    RewriteBase /\n    RewriteRule ^index\\.html$ - [L]\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteCond %{REQUEST_FILENAME} !-d\n    RewriteRule . /index.html [L]\n\u003c/IfModule\u003e\n```\n\nor with a node.js via a simple Express.js server:\n\n```js\nconst express = require(\"express\");\nconst path = require(\"path\");\nconst port = process.env.PORT || 3000;\nconst app = express();\nconst fs = require(\"fs\");\n\napp.use(express.static(__dirname + \"/dist\"));\napp.get(\"*\", function(request, response) {\n  response.sendFile(path.resolve(__dirname, \"dist\", \"index.html\"));\n});\napp.listen(port);\n```\n\n## How to run this\n\nTo run with all the features, including stateless entry, you can either run it with Node (easy) or Apache (requires Docker):\n\n### With Node.js\n\n```sh\n# Install dependencies for the app\nnpm install\n\n# Use webpack to build a single application JS bundle\nnpm build\n\n# Start a simple Express.js server\nnpm run dev\n```\n\n### With Apache (via Docker)\n\n```sh\n# Install dependencies for the app\nnpm install\n\n# Use webpack to build a single application JS bundle\nnpm build\n\n# Build the Docker image\ndocker build -t apache .\n\n# Run it on port 8080 (in the foreground)\ndocker run -p 8080:80 apache\n```\n\n### On [Zeit](https://zeit.com) w/ [`now`](https://zeit.co/now):\n\n```sh\nnow .\n```\n\nAlternatively, you can run it without stateless entry by running any webserver.\nI recommend [devd](https://github.com/cortesi/devd).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famoeba%2Fbackbone-pushstate-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famoeba%2Fbackbone-pushstate-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famoeba%2Fbackbone-pushstate-example/lists"}