https://github.com/toomanybees/river-site
https://github.com/toomanybees/river-site
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/toomanybees/river-site
- Owner: TooManyBees
- Created: 2019-01-11T04:01:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-03T07:02:25.000Z (over 7 years ago)
- Last Synced: 2025-01-17T23:15:31.261Z (over 1 year ago)
- Language: Ruby
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Netlify + Dropbox client site
Based almost completely on jimniels's [netlibox](https://github.com/jimniels/netlibox/) template, with modifications:
* lambda function verifies the Dropbox signature before triggering build (were we... were we just gonna go on honor system here???)
* no NPM or Babel needed
* the lambda function, is valid Node 8 LTS
* fetching dropbox content is done in ruby, since we're using it for Jekyll anyway
* thank heavens
* downloaded pages will clobber duplicate files that already exist in the repo, even if they have different extensions like `.md` and `.markdown`. (The list of extensions is defined in `dropbox.rb`'s `POST_EXTNAMES` constant.)
# Setup
Firstly, there is nothing special happening in `./app`. It contains a Jekyll new site boilerplate, with the exception of `_config.yml`, `Gemfile`, and `Gemfile.lock` that remain in the top level directory.
The only change of consequence in `_config.yml` is the line
```yaml
source: "./app"
```
In Dropbox:
1. https://www.dropbox.com/developers/apps → **Create App**
2. Pick Dropbox API, limit to App Folder
3. **App secret** → **Show**, save for later as `DROPBOX_APP_SECRET`
4. **OAuth2** → **Allow Implicit Grants** → **Disallow**
5. **OAuth2** → **Generate access token**, save for later as `DROPBOX_ACCESS_TOKEN`
In source code:
1. Consider renaming `functions/dropbox-webhook.js` because Netlify will mount it at a predictable path based on its file name, and that would allow someone to maliciously use up your monthly Function quota.
In Netlify:
1. Create a Git-based app (otherwise it will not support build hooks)
2. Go to (on top nav) **Settings** → **Build & Deploy** → **Continuous Deployment**
3. **Build hooks** → **Add Build Hook**, name it anything (`dropbox-webhook` is good), save generated url for later as `NETLIFY_BUILD_HOOK_URL`
4. In **Build environment variables** → **Edit variables**, create these variables with the values saved from earlier
1. `DROPBOX_APP_SECRET`
2. `DROPBOX_ACCESS_TOKEN`
3. `NETLIFY_BUILD_HOOK_URL`
5. Go to (on top nav) **Functions**. It may take a while to populate the list of functions after initial deploy.
6. Go to function `dropbox-webhook.js` (unless you renamed it), copy the **Endpoint** url, save for later
Back in Dropbox app settings:
1. **Webhooks** → **Add**, with the function url you just saved. Its status should quickly change to *Enabled*. If not, look in the Netlify function log (on the page that lists its URL) and check if the function is being invoked at all. It should look like:
```
8:07:43 AM: dropbox-webhook invoked
8:07:43 AM: Echoing challenge 2_mLAgJwloCKup6nTktFXFA131c2ycyJmjtzd_Rc9HY
```
# Usage
In Dropbox, upload files to the app folder using the same directory structure that Jekyll expects (remembering to put posts in a `_posts` folder). You can overwrite `index.md`, `about.md`, `404.html`, or any other page in the repo, even if the extensions differ.
The app will rebuild on changes to the Dropbox app folder or the source repo.