Remove URL reversing
This commit is contained in:
parent
38f4c7a041
commit
3f11b1cc18
3 changed files with 14 additions and 67 deletions
|
@ -1,29 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Reverser from '../../helpers/reverser';
|
|
||||||
|
|
||||||
|
|
||||||
export default class Item extends React.Component {
|
export default class Item extends React.Component {
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.state = {
|
|
||||||
url: '#'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if (!this.props.href && !this.props.ident) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.props.href) {
|
|
||||||
this.setState({url: this.props.href});
|
|
||||||
} else {
|
|
||||||
Reverser(this.props.ident, this.props.args, function (url) {
|
|
||||||
this.setState({ url });
|
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
render() {
|
render() {
|
||||||
|
const href = this.props.href.endsWith('/') ? this.props.href : this.props.href + '/';
|
||||||
let icon;
|
let icon;
|
||||||
if (this.props.icon) {
|
if (this.props.icon) {
|
||||||
if (this.props.icon.startsWith('ion')) {
|
if (this.props.icon.startsWith('ion')) {
|
||||||
|
@ -37,7 +17,7 @@ export default class Item extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<li><a href={this.state.url}>{icon}{this.props.children}</a></li>
|
<li><a href={href}>{icon}{this.props.children}</a></li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,15 @@ export default class NavBar extends React.Component {
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="nav navbar-nav" id="navigation">
|
<ul className="nav navbar-nav" id="navigation">
|
||||||
<Dropdown title="Projects">
|
<Dropdown title="Projects">
|
||||||
<Item ident="projects:project" args={['pithos']} icon="ion-social-freebsd-devil">Pithos</Item>
|
<Item href="/projects/pithos/" icon="ion-social-freebsd-devil">Pithos</Item>
|
||||||
<Item ident="projects:project" args={['bsod-enabler']} icon="ion-ios-monitor">BSOD Enabler</Item>
|
<Item href="/projects/bsod-enabler/" icon="ion-ios-monitor">BSOD Enabler</Item>
|
||||||
<Item
|
<Item
|
||||||
ident="projects:project"
|
href="/projects/hipchat-emoticons-for-all/"
|
||||||
args={['hipchat-emoticons-for-all']}
|
icon="ion-chatbox-working">
|
||||||
icon="ion-chatbox-working">Hipchat Emoticons for All</Item>
|
Hipchat Emoticons for All
|
||||||
|
</Item>
|
||||||
<Item href="#" icon="ion-social-windows">Custom PC</Item>
|
<Item href="#" icon="ion-social-windows">Custom PC</Item>
|
||||||
<Item ident="projects:all" icon="ion-android-more-vertical">All Projects...</Item>
|
<Item href="/projects/all/" icon="ion-android-more-vertical">All Projects...</Item>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Dropdown title="Code">
|
<Dropdown title="Code">
|
||||||
<Item href="#" icon="ion-code-working">Code Challenges</Item>
|
<Item href="#" icon="ion-code-working">Code Challenges</Item>
|
||||||
|
@ -33,9 +34,9 @@ export default class NavBar extends React.Component {
|
||||||
<Item href="#" icon="ion-ios-game-controller-a">The Wiki Game Solver</Item>
|
<Item href="#" icon="ion-ios-game-controller-a">The Wiki Game Solver</Item>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Dropdown title="College">
|
<Dropdown title="College">
|
||||||
<Item ident="robotics:index">Student Robotics</Item>
|
<Item href="/robotics">Student Robotics</Item>
|
||||||
<Item ident="college:attack-on-blocks" icon="ion-cube">Attack on Blocks Game</Item>
|
<Item href="/college/attack-on-blocks" icon="ion-cube">Attack on Blocks Game</Item>
|
||||||
<Item ident="college:student-server" icon="glyphicon-hdd">Student Server</Item>
|
<Item href="/college/student-server" icon="glyphicon-hdd">Student Server</Item>
|
||||||
<Item href="#" icon="ion-ios-paper">EPQ</Item>
|
<Item href="#" icon="ion-ios-paper">EPQ</Item>
|
||||||
<Item href="#">Wall of Sheep</Item>
|
<Item href="#">Wall of Sheep</Item>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
@ -61,9 +62,8 @@ export default class NavBar extends React.Component {
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Item href="#">Links</Item>
|
<Item href="#">Links</Item>
|
||||||
<Dropdown title="About">
|
<Dropdown title="About">
|
||||||
<Item ident="about:me" icon="ion-android-person">Me</Item>
|
<Item href="/about/me" icon="ion-android-person">Me</Item>
|
||||||
<Item ident="about:website" icon="ion-cloud">Website</Item>
|
<Item href="/about/website" icon="ion-cloud">Website</Item>
|
||||||
<Item ident="about:index" icon="ion-android-contacts">Contact Me</Item>
|
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
export default function Reverser(ident, args, onSuccess) {
|
|
||||||
let body = {};
|
|
||||||
if (ident) {
|
|
||||||
body.ident = ident;
|
|
||||||
if (args) {
|
|
||||||
body.args = args;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (body !== {}) {
|
|
||||||
body = JSON.stringify(body);
|
|
||||||
fetch('/reverse/', {
|
|
||||||
method: 'post',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.status === 302) {
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
var error = new Error(response.statusText);
|
|
||||||
error.response = response;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}).then(
|
|
||||||
(response) => response.json()
|
|
||||||
).then(onSuccess)
|
|
||||||
.catch(function (err) {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Reference in a new issue