Permalink
Browse files

Switching to the new admin templates and removing old jade files

  • Loading branch information...
1 parent f668030 commit ca95e926cd5b865c35475b93139b4db50f3a841a @JedWatson JedWatson committed Sep 3, 2015
View
@@ -19,7 +19,7 @@ function render(req, res, view, ext) {
var keystone = this;
- var templatePath = __dirname + '/../../templates/views/' + view + '.jade';
+ var templatePath = __dirname + '/../../admin/templates/' + view + '.jade';
debug('rendering ' + templatePath);
@@ -28,11 +28,6 @@ function render(req, res, view, ext) {
pretty: keystone.get('env') !== 'production'
};
- // TODO: Allow custom basePath for extensions... like this or similar
- // if (keystone.get('extensions')) {
- // jadeOptions.basedir = keystone.getPath('extensions') + '/templates';
- // }
-
var compileTemplate = function() {
debug('compiling');
return jade.compile(fs.readFileSync(templatePath, 'utf8'), jadeOptions);
@@ -128,7 +123,7 @@ function render(req, res, view, ext) {
var html = template(_.extend(locals, ext));
- debug('sending down html');
+ debug('sending html');
res.send(html);
}
@@ -1,132 +0,0 @@
-include ../mixins/flashMessages
-
-doctype html
-html
- head
- meta(charset="utf-8")
- meta(name="viewport", content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width")
- meta(name="csrf-token", content="#{csrf_token_value}")
-
- title= title
-
- //- Component Stylesheets
- link(rel="stylesheet", href="/keystone/js/lib/select2/select2-3.3.2.css")
- link(rel="stylesheet", href="/keystone/js/lib/pikaday/pikaday-1.1.0.css")
-
- //- Keystone Stylesheet
- link(rel="stylesheet", href="/keystone/styles/keystone.min.css")
- block css
-
- link(rel="shortcut icon", href="/favicon.ico", type="image/x-icon")
- block head
-
- body(id='page-' + page)
- .keystone-wrapper
- header.keystone-navigation
- nav.primary-navbar
- .container
- ul.app-nav.app-nav--primary.app-nav--left
- li(class=!section.key ? 'active' : null)
- a(href='/keystone' title='Dashboard - ' + brand tabIndex="-1")
- span.octicon.octicon-home
- each navSection in nav.sections
- if navSection.lists[0].external
- - path = navSection.lists[0].path
- else
- - path = '/keystone/' + navSection.lists[0].path
-
- li(class=section.key == navSection.key ? 'active' : null)
- a(href=path tabIndex="-1")= navSection.label
- if signout
- ul.app-nav.app-nav--primary.app-nav--right
- li
- a(href=signout title="Sign Out" tabIndex="-1").signout
- span.octicon.octicon-sign-out
- if section.lists && section.lists.length > 1
- nav.secondary-navbar
- .container
- ul.app-nav.app-nav--secondary.app-nav--left
- each navList in section.lists
- if navList.external
- - path = navList.path
- else
- - path = '/keystone/' + navList.path
-
- li(class=navList.key == list.key ? 'active' : null): a(href=path tabIndex="-1")= navList.label
- .keystone-body
- +flash-messages(messages)
- block content
-
- footer.keystone-footer
- .container
- a(href=backUrl tabIndex="-1").keystone-footer__link #{brand + (appversion ? (' ' + appversion) : '')}
- | Powered by <a href="http://keystonejs.com" target="_blank" class="keystone-footer__link" tabIndex="-1">KeystoneJS</a> version #{version}.
- if User && user
- | Signed in as
- a(href='/keystone/' + User.path + '/' + user.id tabIndex="-1").keystone-footer__link= User.getDocumentName(user)
- | .
-
- //- Common
- script(src="/keystone/js/lib/underscore/underscore-1.5.1.min.js")
- script(src="/keystone/js/lib/jquery/jquery-1.10.2.min.js")
- script(src="/keystone/js/lib/async/async.js")
-
- //- Bootstrap Components
- script(src='/keystone/js/lib/bootstrap/collapse.js')
- script(src='/keystone/js/lib/bootstrap/dropdown.js')
- script(src='/keystone/js/lib/bootstrap/tooltip.js')
- script(src='/keystone/js/lib/bootstrap/button.js')
-
- //- Other Components
- script(src="/keystone/js/lib/moment/moment-1.7.2.min.js")
- script(src="/keystone/js/lib/move/move-0.1.1.min.js")
- script(src="/keystone/js/lib/select2/select2-3.3.2.min.js")
- script(src="/keystone/js/lib/pikaday/pikaday-1.1.0.js")
- script(src="/keystone/js/lib/pikaday/pikaday.jquery-1.1.0.js")
- script(src="/keystone/js/lib/jquery-placeholder-shim/jquery-placeholder-shim.js")
- script(src="/keystone/js/lib/tinymce/tinymce.min.js")
- block js_codemirror
-
- //- App
- script.
- var Keystone = {};
- Keystone.csrf = function(obj) {
- obj['#{csrf_token_key}'] = "#{csrf_token_value}";
- return obj;
- };
- Keystone.csrf.header = { "!{csrf_header_key}": "!{csrf_token_value}" };
- Keystone.csrf.key = "#{csrf_token_key}";
- Keystone.csrf.value = "#{csrf_token_value}";
- Keystone.csrf.query = "!{csrf_query}";
- if cloudinary
- script(src='/keystone/js/lib/jqueryfileupload/vendor/jquery.ui.widget.js')
- script(src='/keystone/js/lib/jqueryfileupload/jquery.iframe-transport.js')
- script(src='/keystone/js/lib/jqueryfileupload/jquery.fileupload.js')
- script(src='/keystone/js/lib/cloudinary/jquery.cloudinary.js')
- | !{cloudinary_js_config}
- script.
- Keystone.cloudinary = {
- cloud_name: "#{cloudinary.cloud_name}",
- api_key: "#{cloudinary.api_key}",
- timestamp: "#{cloudinary.timestamp}",
- signature: "#{cloudinary.signature}"
- }
-
- //- Keystone UI
- script(src="/keystone/js/common/plugins.js")
- script(src="/keystone/js/common/ui.js")
- script(src="/keystone/js/common/ui-alt-text.js")
- script(src="/keystone/js/common/ui-sortable.js")
-
- //- Page Scripts
- block js
-
- //- Google Analytics
- if env == 'production' && ga.property && ga.domain
- script.
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- ga('create', '#{ga.property}', '#{ga.domain}');
- ga('send', 'pageview');
@@ -1,66 +0,0 @@
-mixin column(list, col, item)
- if col.type == 'relationship'
- - var refData = item.get(col.path)
- if col.field.many
- if Array.isArray(refData) && refData.length
- div.ItemList__col-value
- - var values = []
- - _.first(refData, 3).forEach(function(i) { values.push(col.subField ? col.subField.format(i) : i[col.refPath]) })
- = values.join(', ')
- if refData.length > 3
- | ... (#{refData.length - 3} more)
- else if refData
- if (col.subField && col.subField.type == 'boolean' && !col.many)
- +column_boolean(refData[col.refPath])
- else
- - var value = col.subField ? col.subField.format(refData) : refData[col.refPath]
- if col.refList && refData && refData.id
- +column_link(value, '/keystone/' + col.refList.path + '/' + refData.id)
- else
- +column_basic(value)
- else if col.type == 'markdown'
- +column_html(utils.textToHTML(utils.cropString(item.get(col.field.paths.md), 200, '...', true)))
- else if col.type == 'html'
- +column_html(utils.cropHTMLString(item.get(col.field.path), 200, '...', true))
- else
- - var value = col.field ? col.field.format(item) : item.get(col.path)
- if col.isName
- +column_link(value || '(no name)', '/keystone/' + list.path + '/' + item.id)
- else if col.type == 'email'
- if value && col.field.options.displayGravatar
- +column_gravatar(col.field.gravatarUrl(item,35))
- +column_link(value, 'mailto:' + value)
- else if col.type == 'boolean'
- +column_boolean(value)
- else if col.type == 'url'
- +column_link(value, value, true)
- else if col.type == 'color'
- +column_color(value)
- else if col.type == 'localfile'
- +column_html(value)
- else
- +column_basic(value)
-
-mixin column_link(value, href, newWindow)
- if value
- a(href=href, target=newWindow ? '_blank' : undefined)= value
-
-mixin column_gravatar(src)
- img(src=src).img-thumbnail
-
-mixin column_boolean(value)
- if (value)
- img(src='/keystone/images/icons/16/checkbox-checked.png', width=16, height=16)
- else
- img(src='/keystone/images/icons/16/checkbox-unchecked.png', width=16, height=16)
-
-mixin column_html(value)
- div.ItemList__col-value!= value
-
-mixin column_basic(value)
- div.ItemList__col-value= value
-
-mixin column_color(value)
- div.ItemList__col-value
- if (value)
- div.color-preview(style={'background-color': value})
@@ -1,25 +0,0 @@
-mixin flash-messages(messages)
- if messages
- .flash-messages: .container
- each message in messages.info
- +flash-message(message, 'info')
- each message in messages.success
- +flash-message(message, 'success')
- each message in messages.warning
- +flash-message(message, 'warning')
- each message in messages.error
- +flash-message(message, 'danger')
-
-mixin flash-message(message, type)
- div(class='Alert Alert--' + type)
- if utils.isObject(message)
- if message.title
- h4= message.title
- if message.detail
- p= message.detail
- if message.list
- ul
- each item in message.list
- li= item
- else
- = message
@@ -1,5 +0,0 @@
-mixin pagination(items)
- .count Showing #{items.first} to #{items.last} of #{items.total}
- ul.pagination: each p, i in items.pages
- li(class=items.currentPage == p ? 'active' : null)
- a(href=(p == '...' ? link_to({page: (i ? items.totalPages : 1)}) : link_to({page: p})))= p
@@ -1,13 +0,0 @@
-include columns
-
-mixin row(list, colums, item)
- tr(id=item.id)
- if !list.get('nodelete') && ( !user || (user && item.id !== user.id ) )
- td.control: a(href='/keystone/' + list.path + '?delete=' + item.id + csrf_query).control-delete
- else if !list.get('nodelete')
- td.control
- if sortable && !xFilters
- td.control: a(href=js).control-sort
- each col, i in columns
- td
- +column(list, col, item)
@@ -1,3 +0,0 @@
-include ../mixins/pagination.jade
-
-+pagination(items)
@@ -1,3 +0,0 @@
-include ../mixins/rows.jade
-
-+row(list, colums, item)
@@ -1,14 +0,0 @@
-extends ../layout/base
-
-block js
- - var getListMeta = function(list) { return _.pick(list, ['key', 'label', 'path']); }
- script.
- Keystone.nav = !{JSON.stringify(nav)};
- Keystone.lists = !{JSON.stringify(_.map(lists, getListMeta))};
- Keystone.orphanedLists = !{JSON.stringify(orphanedLists.map(getListMeta))};
- Keystone.brand = !{JSON.stringify(brand)};
- script(src='/keystone/js/packages.js')
- script(src='/keystone/js/home.js')
-
-block content
- #home-view
@@ -1,56 +0,0 @@
-extends ../layout/base
-
-include ../mixins/columns
-
-block css
- if list.fieldTypes.code
- link(rel='stylesheet', href='/keystone/js/lib/codemirror/codemirror.css')
-
-block js
- script.
- Keystone.list = !{JSON.stringify(list.getOptions())};
- Keystone.wysiwyg = { options: !{JSON.stringify(wysiwygOptions)} };
- Keystone.itemId = '!{item.id}';
- script(src='/keystone/js/packages.js')
- script(src='/keystone/js/fields.js')
- script(src='/keystone/js/item.js')
-
-block js_codemirror
- if list.fieldTypes.code
- script(src="/keystone/js/lib/codemirror/codemirror-compressed.js")
-
-block content
- // Attach point for new React View
- div#item-view
-
- if showRelationships
- .EditForm__relationships
- .container
- h2.EditForm__relationships-heading Relationships
- each rel in relationships
- if rel.items.results.length
- h3.EditForm__relationships-subheading
- a(href='/keystone/' + rel.list.path)= (rel.label) ? rel.label : rel.list.label
- if rel.note
- .field-note= rel.note
- - var firstColspan = 1
- table(cellpadding=0, cellspacing=0, class=rel.sortable ? 'sortable' : false, data-list-path=rel.list.path).Table.ItemList.relationships-list
- if rel.sortable
- - firstColspan++;
- col(width=26)
- each col in rel.columns
- col(width=col.width)
- thead
- tr
- each col, i in rel.columns
- th(colspan=i == 0 && firstColspan > 1 ? firstColspan : false)= col.label
- tbody
- each item in rel.items.results
- tr(id=item.id)
- if rel.sortable
- td.control: a(href=js).control-sort
- each col, i in rel.columns
- td
- +column(rel.list, col, item)
-
-
@@ -1,37 +0,0 @@
-extends ../layout/base
-
-include ../mixins/rows
-include ../mixins/pagination
-
-block js
- script(src='/keystone/js/views/list.js')
- script(src='/keystone/js/lib/browserified/querystring.js')
- script(src='/keystone/js/lib/browserified/queryfilter.js')
- script.
- Keystone.list = !{JSON.stringify(list.getOptions())};
- Keystone.wysiwyg = { options: !{JSON.stringify(wysiwygOptions)} };
-
- // Support for the POST-based create process
- Keystone.showCreateForm = !{JSON.stringify(showCreateForm)};
- Keystone.createFormData = !{JSON.stringify(submitted)};
- Keystone.createFormErrors = !{JSON.stringify(createErrors || null)};
-
- // Support for React-rendered List view
- Keystone.columns = !{JSON.stringify(columns)};
-
- // Legacy data for List view
- Keystone.list.cols = !{JSON.stringify(colPaths)};
- Keystone.list.perPage = !{ Number(list.perPage) || 50 };
- Keystone.search = '#{search}';
- Keystone.filters = !{ JSON.stringify(filters) };
- Keystone.sort = '#{sort.by}';
- Keystone.query = '#{query}';
- Keystone.csrf_query = '!{csrf_query}';
- script(src='/keystone/js/packages.js')
- script(src='/keystone/js/fields.js')
- script(src='/keystone/js/list.js')
-
-block content
- //- New React View
- //- ------------------------------
- #list-view

0 comments on commit ca95e92

Please sign in to comment.