Skip to content

Instantly share code, notes, and snippets.

View jeffreypriebe's full-sized avatar

Jeffrey Priebe jeffreypriebe

View GitHub Profile
@jeffreypriebe
jeffreypriebe / .babelrc
Last active November 3, 2018 01:16
Convert from flow to Typescript
# note: this does not convert anything with jsx - if you use the babel plugin for jsx it works, but rewrites it to react.createElement stuff
{
"presets": [],
"plugins": [
"flow-to-typescript"
]
}
@jeffreypriebe
jeffreypriebe / Readme.md
Last active March 17, 2018 09:50
Keystone Admin User Role Permissions

The admin-user-roles-permissions has basic support for handling user permissions in the Keystone admin area.

It is comprised of basic parts:

  1. Additional fields on the user model (mentioned in steps below and also the User.js file)

    • isUserAdmin, isSuperAdmin and isPWD (the last one has permissions to edit any other user always)
    • Simply, each user has the ability to edit self and all users with fewer permissions.
  2. Exposure of these values (via virtuals) to the React admin/src/views/item.js route and to the server side jade templates and express routes.

@jeffreypriebe
jeffreypriebe / Model.js
Created January 15, 2016 04:42
Parts of code to send email on change of a Keystone Model
//Add this to the model that will be sending email
//It doesn't have to form part of the model, but it follows what we see elsewhere in Keystone, e.g. https://github.com/JedWatson/sydjs-site/blob/master/models/Post.js
//Swap out the model name of users to lookup and input your own values for the email
var mailer = require('mailer.js');
//monkey patch in async saves in mongoose 3.x, h/t:http://stackoverflow.com/a/26049430/1592 , https://github.com/Automattic/mongoose/issues/787#issuecomment-56896373
var notifyUsers = function(callback) {
app.all('/keystone/{SINGLE_ITEM_MODEL}', function(req, res, next) {
req.params.list = '{SINGLE_ITEM_MODEL}';
req.params.item = keystone.get({Id of Single Item});
next();
}, initList(true), require('../../admin/routes/views/item'));
app.all('/keystone/{SINGLE_ITEM_MODEL}/:item', function(req, res, next) {
res.redirect('/keystone/{SINGLE_ITEM_MODEL}}');
});
@jeffreypriebe
jeffreypriebe / notes.md
Last active September 28, 2018 17:14 — forked from JedWatson/notes.md

Creating new Field Types for KeystoneJS

We're currently working on making it easier to add new field types to KeystoneJS as plugins.

In the meantime, if you'd like to work on your own field type, hopefully this guide will point you in the right direction.

Keystone fields require the following:

  • a {fieldType}.js file in ./lib/fieldTypes that controls the field and encapsulates options support, underscore functions, validation and updating
  • the {fieldType}.js file needs to be included by ./lib/fieldTypes.js
/* font-face form icons.ie7.less - really should be extracted out and shared */
@font-face {
font-family: 'icomoon';
src:url('fonts/icomoon.eot');
src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
url('fonts/icomoon.svg#icomoon') format('svg'),
url('fonts/icomoon.woff') format('woff'),
url('fonts/icomoon.ttf') format('truetype');
font-weight: normal;
font-style: normal;
@jeffreypriebe
jeffreypriebe / KeystoneBasePageHistoryInheritance
Last active August 29, 2015 14:24
Keystone BasePage History Inheritance Error
var keystone = require('keystone');
var BasePage = new keystone.List('BasePage', {
map: { name: 'title' },
autokey: { path: 'slug', from: 'title', unique: true },
history: true //<=== This is the single change from the example in the docs.
});
BasePage.add({
title: { type: String, required: true },
slug: { type: String, readonly: true },
-- Uncomment below to verify the number of nodes returned is the same as the number of nodes that is in the Recycle Bin
-- SELECT * FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20
--Setup the temporary table
CREATE TABLE #temp ([id] int);
INSERT #temp select id from umbracoNode where path like '%-20%' and id!=-20
-- Delete all 'related' nodes and table contents...
DELETE FROM cmsPreviewXml WHERE nodeId IN (SELECT id FROM #temp)
DELETE FROM cmsContentVersion WHERE contentId IN (SELECT id FROM #temp)