Skip to content

Commit b46b116

Browse files
committed
Merge branch 'race' of https://github.com/jekyll/jekyll-admin into race
2 parents d66c26d + 2f1f28a commit b46b116

File tree

23 files changed

+1502
-534
lines changed

23 files changed

+1502
-534
lines changed

lib/jekyll-admin/apiable.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def to_api(include_content: false)
4747
output["name"] = basename
4848
end
4949

50+
if is_a?(Jekyll::StaticFile)
51+
output["from_theme"] = from_theme_gem?
52+
end
53+
5054
output
5155
end
5256

@@ -61,6 +65,10 @@ def file_path
6165
end
6266
end
6367

68+
def from_theme_gem?
69+
@base == site.in_theme_dir
70+
end
71+
6472
# StaticFiles don't have `attr_accesor` set for @site or @name
6573
def site
6674
@site

lib/jekyll-admin/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JekyllAdmin
2-
VERSION = "0.5.1".freeze
2+
VERSION = "0.6.0".freeze
33
end

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jekyll-admin",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "Admin Panel for Jekyll",
55
"private": true,
66
"scripts": {
@@ -36,6 +36,7 @@
3636
"moment": "2.17.1",
3737
"react": "15.4.1",
3838
"react-ace": "4.1.5",
39+
"react-document-title": "^2.0.3",
3940
"react-dom": "15.4.1",
4041
"react-dropzone": "3.10.0",
4142
"react-hotkeys": "^0.9.0",
@@ -102,7 +103,9 @@
102103
"\\.(css|scss)$": "identity-obj-proxy",
103104
"^.+\\.(gif|ttf|eot|svg|woff|woff2|ico)$": "<rootDir>/tools/fileMock.js"
104105
},
105-
"roots": ["src"],
106+
"roots": [
107+
"src"
108+
],
106109
"testMatch": [
107110
"**/*.spec.js"
108111
]

src/components/FilePreview.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,25 @@ export default class FilePreview extends Component {
3030
} else {
3131
nodeLink = <a href={file.http_url} target="_blank">{node}</a>;
3232
}
33+
34+
let overlay;
35+
if (file.from_theme) {
36+
overlay = (
37+
<span className="theme-indicator">
38+
<i className="fa fa-diamond" aria-hidden="true" title="Theme Asset" />
39+
</span>
40+
);
41+
} else {
42+
overlay = (
43+
<button onClick={() => this.handleClickDelete(file.path)} className="delete" title="Delete file">x</button>
44+
);
45+
}
46+
3347
return (
3448
<div className="file-preview">
49+
{overlay}
3550
{nodeLink}
3651
<span className="filename">{file.path}</span>
37-
<button onClick={() => this.handleClickDelete(file.path)} className="delete" title="Delete file">x</button>
3852
</div>
3953
);
4054
}

src/components/metadata/MetaField.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import MetaButtons from './MetaButtons';
77

88
export class MetaField extends Component {
99

10+
componentDidMount() {
11+
const isNewField = /New field/.test(this.props.fieldKey);
12+
isNewField && this.refs.field_key.select();
13+
}
14+
1015
handleConvertClick(type) {
1116
const { convertField, nameAttr } = this.props;
1217
convertField(nameAttr, type);

src/components/tests/filepreview.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function setup(file=staticfile) {
1919
filename: component.find('.filename'),
2020
image: component.find('img'),
2121
div: component.find('.file-preview a div'),
22+
indicator: component.find('.file-preview .theme-indicator'),
23+
delete_btn: component.find('.file-preview .delete'),
2224
actions: actions
2325
};
2426
}
@@ -29,9 +31,20 @@ describe('Components::FilePreview', () => {
2931
expect(image.node).toBeTruthy();
3032
expect(div.node).toBeFalsy();
3133
});
34+
3235
it('should render a div if the file does not have an image extension', () => {
3336
const { image, div } = setup({...staticfile, extname: 'html'});
3437
expect(image.node).toBeFalsy();
3538
expect(div.node).toBeTruthy();
3639
});
40+
41+
it('should render an indicator if file is from theme-gem', () => {
42+
const { indicator } = setup({...staticfile, from_theme: true});
43+
expect(indicator.node).toBeTruthy();
44+
});
45+
46+
it('should not render a delete-button if file is from theme-gem', () => {
47+
const { delete_btn } = setup({...staticfile, from_theme: true});
48+
expect(delete_btn.node).toBeFalsy();
49+
});
3750
});

src/constants/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const VERSION = 'v0.5.1';
1+
export const VERSION = 'v0.6.0';
22
export const ADMIN_PREFIX = '/admin';

src/constants/lang/da.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const labels = {
7575
label: 'Upload filer'
7676
},
7777
viewToggle: {
78-
label: 'Skift Udsigt til Raw Editor',
79-
triggeredLabel: 'Skift Udsigt til Raw Editor'
78+
label: 'Skift visning til grafisk redigering',
79+
triggeredLabel: 'Skift visning til tekst redigering'
8080
}
8181
};

src/containers/App.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component, PropTypes } from 'react';
22
import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
44
import { HotKeys } from 'react-hotkeys';
5+
import DocumentTitle from 'react-document-title';
56

67
import { fetchConfig } from '../actions/config';
78
import keyboardShortcuts from '../constants/keyboardShortcuts';
@@ -33,23 +34,25 @@ class App extends Component {
3334
}
3435

3536
return (
36-
<HotKeys
37-
keyMap={keyboardShortcuts}
38-
className="wrapper">
39-
{
40-
config.content &&
41-
<div>
42-
<Sidebar config={config.content} />
43-
<div className="container">
44-
<Header config={config.content} />
45-
<div className="content">
46-
{this.props.children}
37+
<DocumentTitle title="Jekyll Admin">
38+
<HotKeys
39+
keyMap={keyboardShortcuts}
40+
className="wrapper">
41+
{
42+
config.content &&
43+
<div>
44+
<Sidebar config={config.content} />
45+
<div className="container">
46+
<Header config={config.content} />
47+
<div className="content">
48+
{this.props.children}
49+
</div>
4750
</div>
51+
<Notifications />
4852
</div>
49-
<Notifications />
50-
</div>
51-
}
52-
</HotKeys>
53+
}
54+
</HotKeys>
55+
</DocumentTitle>
5356
);
5457
}
5558
}

src/containers/views/Configuration.js

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
44
import { withRouter } from 'react-router';
55
import { HotKeys } from 'react-hotkeys';
6+
import DocumentTitle from 'react-document-title';
67
import DataGUI from '../MetaFields';
78
import Editor from '../../components/Editor';
89
import Errors from '../../components/Errors';
@@ -71,44 +72,46 @@ export class Configuration extends Component {
7172
};
7273

7374
return (
74-
<HotKeys handlers={keyboardHandlers} className="single">
75-
{errors && errors.length > 0 && <Errors errors={errors} />}
76-
<div className="content-header">
77-
<h1>Configuration</h1>
78-
<div className="page-buttons multiple">
79-
<Button // TODO: Hide toggle for non-YAML config files (e.g. '_config.toml')
80-
onClick={this.toggleView}
81-
type="view-toggle"
82-
active={true}
83-
triggered={this.state.guiView}
84-
block />
85-
<Button
86-
onClick={this.handleClickSave}
87-
type="save"
88-
active={editorChanged || fieldChanged}
89-
triggered={updated}
90-
block />
75+
<DocumentTitle title="Configuration">
76+
<HotKeys handlers={keyboardHandlers} className="single">
77+
{errors && errors.length > 0 && <Errors errors={errors} />}
78+
<div className="content-header">
79+
<h1>Configuration</h1>
80+
<div className="page-buttons multiple">
81+
<Button // TODO: Hide toggle for non-YAML config files (e.g. '_config.toml')
82+
onClick={this.toggleView}
83+
type="view-toggle"
84+
active={true}
85+
triggered={this.state.guiView}
86+
block />
87+
<Button
88+
onClick={this.handleClickSave}
89+
type="save"
90+
active={editorChanged || fieldChanged}
91+
triggered={updated}
92+
block />
93+
</div>
9194
</div>
92-
</div>
93-
{
94-
this.state.guiView && content &&
95-
<div className="content-body">
96-
<div className="warning">
97-
CAUTION! Any existing comments and formatting will be lost when editing via this view.
98-
Switch to the <strong>Raw Editor</strong> to preserve comments and formatting.
95+
{
96+
this.state.guiView && content &&
97+
<div className="content-body">
98+
<div className="warning">
99+
CAUTION! Any existing comments and formatting will be lost when editing via this view.
100+
Switch to the <strong>Raw Editor</strong> to preserve comments and formatting.
101+
</div>
102+
<DataGUI fields={content} dataview/>
99103
</div>
100-
<DataGUI fields={content} dataview/>
101-
</div>
104+
}
105+
{
106+
!this.state.guiView && raw_content &&
107+
<Editor
108+
editorChanged={editorChanged}
109+
onEditorChange={onEditorChange}
110+
content={raw_content}
111+
ref="editor" />
102112
}
103-
{
104-
!this.state.guiView && raw_content &&
105-
<Editor
106-
editorChanged={editorChanged}
107-
onEditorChange={onEditorChange}
108-
content={raw_content}
109-
ref="editor" />
110-
}
111-
</HotKeys>
113+
</HotKeys>
114+
</DocumentTitle>
112115
);
113116
}
114117
}

0 commit comments

Comments
 (0)