Skip to content

Commit 7e29088

Browse files
Merge pull request #407 from jekyll/title
Show current page title in browser tab
2 parents 8753840 + 11ee563 commit 7e29088

File tree

14 files changed

+1440
-527
lines changed

14 files changed

+1440
-527
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/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
}

src/containers/views/DataFileEdit.js

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { bindActionCreators } from 'redux';
44
import { browserHistory, withRouter } from 'react-router';
55
import _ from 'underscore';
66
import { HotKeys } from 'react-hotkeys';
7+
import DocumentTitle from 'react-document-title';
78
import DataGUI from '../MetaFields';
89
import Breadcrumbs from '../../components/Breadcrumbs';
910
import InputPath from '../../components/form/InputPath';
@@ -238,45 +239,51 @@ export class DataFileEdit extends Component {
238239
'save': this.handleClickSave,
239240
};
240241

242+
const document_title = directory ?
243+
`${filename} - ${directory} - Data Files` :
244+
`${filename} - Data Files`;
245+
241246
return (
242-
<HotKeys
243-
handlers={keyboardHandlers}
244-
className="single">
245-
{errors.length > 0 && <Errors errors={errors} />}
246-
247-
<div className="content-header">
248-
<Breadcrumbs splat={directory || ''} type="data files" />
249-
</div>
250-
251-
<div className="content-wrapper">
252-
{
253-
this.state.guiView &&
254-
<div className="content-body">
255-
<div className="warning">
256-
CAUTION! Any existing comments will be lost when editing via this view.
257-
Switch to the <strong>Raw Editor</strong> to preserve comments.
247+
<DocumentTitle title={document_title}>
248+
<HotKeys
249+
handlers={keyboardHandlers}
250+
className="single">
251+
{errors.length > 0 && <Errors errors={errors} />}
252+
253+
<div className="content-header">
254+
<Breadcrumbs splat={directory || ''} type="data files" />
255+
</div>
256+
257+
<div className="content-wrapper">
258+
{
259+
this.state.guiView &&
260+
<div className="content-body">
261+
<div className="warning">
262+
CAUTION! Any existing comments will be lost when editing via this view.
263+
Switch to the <strong>Raw Editor</strong> to preserve comments.
264+
</div>
265+
{this.renderGUInputs()}
266+
<DataGUI fields={content} dataview/>
267+
</div>
268+
}
269+
{
270+
!this.state.guiView && raw_content &&
271+
<div className="content-body">
272+
{input_path}
273+
<Editor
274+
editorChanged={datafileChanged}
275+
onEditorChange={onDataFileChanged}
276+
content={raw_content}
277+
type={ext || 'yml'}
278+
ref="editor" />
258279
</div>
259-
{this.renderGUInputs()}
260-
<DataGUI fields={content} dataview/>
261-
</div>
262-
}
263-
{
264-
!this.state.guiView && raw_content &&
265-
<div className="content-body">
266-
{input_path}
267-
<Editor
268-
editorChanged={datafileChanged}
269-
onEditorChange={onDataFileChanged}
270-
content={raw_content}
271-
type={ext || 'yml'}
272-
ref="editor" />
273-
</div>
274-
}
275-
276-
{this.renderAside()}
277-
278-
</div>
279-
</HotKeys>
280+
}
281+
282+
{this.renderAside()}
283+
284+
</div>
285+
</HotKeys>
286+
</DocumentTitle>
280287
);
281288
}
282289
}

src/containers/views/DataFileNew.js

Lines changed: 52 additions & 42 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 { browserHistory, withRouter } from 'react-router';
55
import { HotKeys } from 'react-hotkeys';
6+
import DocumentTitle from 'react-document-title';
67
import DataGUI from '../MetaFields';
78
import Errors from '../../components/Errors';
89
import Editor from '../../components/Editor';
@@ -130,52 +131,61 @@ export class DataFileNew extends Component {
130131
activator = datafileChanged;
131132
}
132133

134+
const document_title = params.splat ?
135+
`New data file - ${params.splat} - Data Files` :
136+
`New data file - Data Files`;
137+
133138
return (
134-
<HotKeys handlers={keyboardHandlers}>
135-
{errors.length > 0 && <Errors errors={errors} />}
136-
<div className="content-header">
137-
<Breadcrumbs splat={params.splat || ''} type="data files" />
138-
</div>
139-
140-
<div className="content-wrapper">
141-
<div className="content-body">
142-
{
143-
this.state.guiView && <div>
144-
{this.renderGUInputs()}
145-
<DataGUI fields={{'key': 'value'}} dataview /></div>
146-
}
147-
{
148-
!this.state.guiView && <div>
149-
<InputPath
150-
onChange={onDataFileChanged}
151-
type="data files"
152-
path=""
153-
ref="inputpath" />
154-
<Editor
155-
editorChanged={datafileChanged}
156-
onEditorChange={onDataFileChanged}
157-
content={''}
158-
ref="editor" /></div>
159-
}
139+
<DocumentTitle title={document_title}>
140+
<HotKeys handlers={keyboardHandlers}>
141+
142+
{errors.length > 0 && <Errors errors={errors} />}
143+
144+
<div className="content-header">
145+
<Breadcrumbs splat={params.splat || ''} type="data files" />
160146
</div>
161147

162-
<div className="content-side">
163-
<Button
164-
onClick={this.handleClickSave}
165-
type="create"
166-
active={activator}
167-
triggered={updated}
168-
icon="plus-square"
169-
block />
170-
<Button
171-
onClick={this.toggleView}
172-
type="view-toggle"
173-
active={true}
174-
triggered={this.state.guiView}
175-
block />
148+
<div className="content-wrapper">
149+
<div className="content-body">
150+
{
151+
this.state.guiView && <div>
152+
{this.renderGUInputs()}
153+
<DataGUI fields={{'key': 'value'}} dataview /></div>
154+
}
155+
{
156+
!this.state.guiView && <div>
157+
<InputPath
158+
onChange={onDataFileChanged}
159+
type="data files"
160+
path=""
161+
ref="inputpath" />
162+
<Editor
163+
editorChanged={datafileChanged}
164+
onEditorChange={onDataFileChanged}
165+
content={''}
166+
ref="editor" /></div>
167+
}
168+
</div>
169+
170+
<div className="content-side">
171+
<Button
172+
onClick={this.handleClickSave}
173+
type="create"
174+
active={activator}
175+
triggered={updated}
176+
icon="plus-square"
177+
block />
178+
<Button
179+
onClick={this.toggleView}
180+
type="view-toggle"
181+
active={true}
182+
triggered={this.state.guiView}
183+
block />
184+
</div>
176185
</div>
177-
</div>
178-
</HotKeys>
186+
187+
</HotKeys>
188+
</DocumentTitle>
179189
);
180190
}
181191
}

0 commit comments

Comments
 (0)