Skip to content

Commit

Permalink
fix(routing): fix JSON output support
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jun 14, 2016
1 parent 81fc388 commit 7e56864
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions website/src/component/container/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export default class App extends React.Component {
<SideEffectLocationHash text={routing.text}/>
<GithubCorner href="https://github.com/azu/morpheme-match"/>
<Title className="App-title"><a href="https://github.com/azu/morpheme-match">morpheme-match</a></Title>
<h2 class="subtitle">形態素解析したトークンを元に、文章にマッチするトークンが含まれているかをチェックするライブラリのデモ</h2>
<h2 className="subtitle">形態素解析したトークンを元に、文章にマッチするトークンが含まれているかをチェックするライブラリのデモ</h2>
<div className="App-container">
<div className="App-InputForm">
<InputForm defaultValue={analyzer.currentText} onSubmit={updateAnalyzedText}/>
</div>
<div className="App-Analyzed">
<AnalyzedTable label="解析結果" tokens={analyzer.tokens}/>
<AnalyzedJSONField permanentURL={analyzer.permanentURL}
<AnalyzedJSONField permanentURL={routing.currentURL}
outputJSON={analyzer.outputJSON}/>
</div>
<div className="App-Test">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class AnalyzedJSONField extends React.Component {
const permanentURL = this.props.permanentURL;
const value = `// ${permanentURL}
${outputJSON}
`
`;
return <div className="AnalyzedJSONField">
<label className="AnalyzedJSONField-label">解析結果(JSON)</label>
<p className="control">
Expand Down
8 changes: 0 additions & 8 deletions website/src/js/store/analyzer/AnalyzerState.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ export default class AnalyzerState extends ReduceState {
}
}

// return "<value>"
get permanentURL() {
const origin = window.location.protocol + "//" + window.location.hostname + (window.location.port
? ":" + window.location.port : "");
const hash = this.currentText ? `#${this.currentText}` : "";
return `${origin}${window.location.pathname}${hash}`;
}

get outputJSON() {
return JSON.stringify(this.tokens, null, 4);
}
Expand Down
7 changes: 7 additions & 0 deletions website/src/js/store/routing/RoutingState.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export default class RoutingState extends ReduceState {
this.text = queryObject.text;
}

get currentURL() {
const origin = window.location.protocol + "//" + window.location.hostname + (window.location.port
? ":" + window.location.port : "");
const query = this.text ? `?text=${this.text}` : "";
return `${origin}${window.location.pathname}${query}`;
}

reduce(payload) {
switch (payload.type) {
case ChangeURLStateUseCase.Events.change:
Expand Down

0 comments on commit 7e56864

Please sign in to comment.