Skip to content

Commit

Permalink
Edit: Rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlelek committed Apr 30, 2024
1 parent a4db93f commit 72c68f4
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images

name: Docker Image CI
name: Docker CI
on:
push:
branches: ["main"]
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/core/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'underscore';
import _s from 'underscore.string';
import yaml from 'js-yaml';
import utils from './utils.js';
import content_processors from '../functions/contentProcessors.js';
import content_processors from '../functions/content_processors.js';

// TODO: Scan on start/change, not on every request
async function handler(activePageSlug, config) {
Expand Down
2 changes: 1 addition & 1 deletion app/core/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs-extra';
import _s from 'underscore.string';
import { marked } from 'marked';
import utils from './utils.js';
import content_processors from '../functions/contentProcessors.js';
import content_processors from '../functions/content_processors.js';

async function handler(filePath, config) {
const contentDir = utils.normalizeDir(path.normalize(config.content_dir));
Expand Down
2 changes: 1 addition & 1 deletion app/core/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path';
import { glob } from 'glob';
import content_processors from '../functions/contentProcessors.js';
import content_processors from '../functions/content_processors.js';
import utils from './utils.js';
import page_handler from './page.js';
import lunr from './lunr.js';
Expand Down
File renamed without changes.
13 changes: 6 additions & 7 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import hogan from 'hogan-express';
import session from 'express-session';
import passport from 'passport';
import language_load from './core/language.js';
import mw_authenticate from './middleware/authenticate.js';
import mw_always_auth from './middleware/always_authenticate.js';
import mw_auth_readonly from './middleware/authenticate_read_access.js';
import mw_error_handler from './middleware/error_handler.js';
import mw_oauth2 from './middleware/oauth2.js';
import mw_authenticate from './middleware/authenticate.mw.js';
import mw_always_auth from './middleware/always_authenticate.mw.js';
import mw_auth_readonly from './middleware/authenticate_read_access.mw.js';
import mw_error_handler from './middleware/error_handler.mw.js';
import mw_oauth2 from './middleware/oauth2.mw.js';
import route_login from './routes/login.route.js';
import route_login_page from './routes/login_page.route.js';
import route_logout from './routes/logout.route.js';
Expand Down Expand Up @@ -44,7 +44,6 @@ function initialize(config) {
// Load Middleware
const authenticate = mw_authenticate(config);
const always_authenticate = mw_always_auth(config);
const authenticate_read_access = mw_auth_readonly(config);
const error_handler = mw_error_handler(config);

// Load Multiple-Use Pages
Expand Down Expand Up @@ -118,7 +117,7 @@ function initialize(config) {
saveUninitialized: false,
}),
);
app.use(authenticate_read_access);
app.use(mw_auth_readonly(config));
// OAuth2
if (config.googleoauth === true) {
app.use(passport.initialize());
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function middleware_authenticate_read_access(config) {
function mw_authenticate_read_access(config) {
if (
config.authentication === true &&
config.authentication_for_edit === false
Expand All @@ -24,4 +24,4 @@ function middleware_authenticate_read_access(config) {
}

// Exports
export default middleware_authenticate_read_access;
export default mw_authenticate_read_access;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Error-Handling Middleware
function handler(config) {
function mw_error_handler(config) {
return function (err, req, res) {
const status = err.status || 500;

Expand All @@ -19,4 +19,4 @@ function handler(config) {
}

// Exports
export default handler;
export default mw_error_handler;
4 changes: 1 addition & 3 deletions app/middleware/oauth2.js → app/middleware/oauth2.mw.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Modules
import express from 'express';

import fetch from 'node-fetch';

// [START setup]
import passport from 'passport';
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';

Expand Down
2 changes: 1 addition & 1 deletion app/routes/sitemap.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import fs from 'fs-extra';
import sm from 'sitemap';
import _ from 'underscore';
import content_processors from '../functions/contentProcessors.js';
import content_processors from '../functions/content_processors.js';
import utils from '../core/utils.js';

function route_sitemap(config) {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/wildcard.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { marked } from 'marked';
import toc from 'markdown-toc';
import build_nested_pages from '../functions/build_nested_pages.js';
import remove_image_content_directory from '../functions/remove_image_content_directory.js';
import content_processors from '../functions/contentProcessors.js';
import content_processors from '../functions/content_processors.js';
import contents_handler from '../core/contents.js';
import utils from '../core/utils.js';

Expand Down
8 changes: 4 additions & 4 deletions content/pages/tutorials/google-oauth-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Install the following packages:
### Editing the `app/index.js` file

+ Add passport: `import passport from 'passport';` just after raneto is required.
+ Add oauth2 middleware: `import oauth2 from './middleware/oauth2.js';` in the config block, just afer `error_handler.js` middleware.
+ Add oauth2 middleware: `import oauth2 from './middleware/oauth2.mw.js';` in the config block, just afer `error_handler.mw.js` middleware.
+ Change `secret` to `secret:config.secret,` in the `// HTTP Authentication` section.
+ >>> Remove the rn-login route `app.post('/rn-login', route_login);`
+ >>> Remove the logout route: `app.get('/logout', route_logout);`
Expand Down Expand Up @@ -78,7 +78,7 @@ else {
}
```

### Editing the `app/middleware/authenticate.js` file
### Editing the `app/middleware/authenticate.mw.js` file
Change the `res.redirect(403, '/login');` line to be:

```
Expand All @@ -102,8 +102,8 @@ return res.render('login', {
});
```

### Add the oauth2.js file
Create a new file `oauth2.js` in the `app/middleware` folder with the following content:
### Add the oauth2.mw.js file
Create a new file `oauth2.mw.js` in the `app/middleware` folder with the following content:

```
// Copyright 2015-2016, Google, Inc.
Expand Down
6 changes: 1 addition & 5 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env node

// Modules
import _debug from 'debug';

// Here is where we load Raneto.
// When you are in your own project repository,
// Raneto should be installed via NPM and loaded as:
Expand All @@ -18,7 +15,6 @@ import config from './config/config.js';
const app = raneto(config);

// Load the HTTP Server
const debug = _debug('raneto');
const server = app.listen(app.get('port'), app.get('host'), () => {
debug(`Express HTTP server listening on port ${server.address().port}`);
console.log(`HTTP server listening on port ${server.address().port}`);
});
2 changes: 1 addition & 1 deletion test/functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import moment from 'moment';
import build_nested_pages from '../app/functions/build_nested_pages.js';
import content_processors from '../app/functions/contentProcessors.js';
import content_processors from '../app/functions/content_processors.js';
import contents_handler from '../app/core/contents.js';
import utils from '../app/core/utils.js';

Expand Down
2 changes: 1 addition & 1 deletion test/raneto-core.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import content_processors from '../app/functions/contentProcessors.js';
import content_processors from '../app/functions/content_processors.js';
import search_handler from '../app/core/search.js';
import page_handler from '../app/core/page.js';
import contents_handler from '../app/core/contents.js';
Expand Down

0 comments on commit 72c68f4

Please sign in to comment.