mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Use query parameters rather than long path
This commit is contained in:
@@ -84,13 +84,13 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "*",
|
"babel-polyfill": "*",
|
||||||
"classnames": "^2.2.0",
|
"classnames": "^2.2.0",
|
||||||
"browserify-zlib": "ipfs/coriolis-data",
|
"browserify-zlib": "ipfs/browserify-zlib",
|
||||||
"coriolis-data": "EDCD/coriolis-data",
|
"coriolis-data": "EDCD/coriolis-data",
|
||||||
"d3": "3.5.16",
|
"d3": "3.5.16",
|
||||||
"fbemitter": "^2.0.0",
|
"fbemitter": "^2.0.0",
|
||||||
"lodash": "^4.15.0",
|
"lodash": "^4.15.0",
|
||||||
"lz-string": "^1.4.4",
|
"lz-string": "^1.4.4",
|
||||||
"react-number-editor": "^4.0.2",
|
"react-number-editor": "Athanasius/react-number-editor.git#miggy",
|
||||||
"react": "^15.0.1",
|
"react": "^15.0.1",
|
||||||
"react-dom": "^15.0.1",
|
"react-dom": "^15.0.1",
|
||||||
"superagent": "^1.4.0"
|
"superagent": "^1.4.0"
|
||||||
|
|||||||
@@ -68,7 +68,10 @@ export default class Coriolis extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Router('', (r) => this._setPage(ShipyardPage, r));
|
Router('', (r) => this._setPage(ShipyardPage, r));
|
||||||
|
Router('/import?', (r) => this._importBuild(r));
|
||||||
Router('/import/:data', (r) => this._importBuild(r));
|
Router('/import/:data', (r) => this._importBuild(r));
|
||||||
|
Router('/outfit/?', (r) => this._setPage(OutfittingPage, r));
|
||||||
|
Router('/outfit/:ship/?', (r) => this._setPage(OutfittingPage, r));
|
||||||
Router('/outfit/:ship/:code?', (r) => this._setPage(OutfittingPage, r));
|
Router('/outfit/:ship/:code?', (r) => this._setPage(OutfittingPage, r));
|
||||||
Router('/compare/:name?', (r) => this._setPage(ComparisonPage, r));
|
Router('/compare/:name?', (r) => this._setPage(ComparisonPage, r));
|
||||||
Router('/comparison/:code', (r) => this._setPage(ComparisonPage, r));
|
Router('/comparison/:code', (r) => this._setPage(ComparisonPage, r));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import TranslatedComponent from './TranslatedComponent';
|
import TranslatedComponent from './TranslatedComponent';
|
||||||
import Link from './Link';
|
import Link from './Link';
|
||||||
import cn from 'classnames';
|
import cn from 'classnames';
|
||||||
|
import { outfitURL } from '../utils/UrlGenerators';
|
||||||
import { SizeMap } from '../shipyard/Constants';
|
import { SizeMap } from '../shipyard/Constants';
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ export default class ComparisonTable extends TranslatedComponent {
|
|||||||
* @return {React.Component} Table row
|
* @return {React.Component} Table row
|
||||||
*/
|
*/
|
||||||
_buildRow(build, facets, formats, units) {
|
_buildRow(build, facets, formats, units) {
|
||||||
let url = `/outfit/${build.id}/${build.toString()}?bn=${build.buildName}`;
|
let url = outfitURL(build.id, build.toString(), build.buildName)
|
||||||
let cells = [
|
let cells = [
|
||||||
<td key='s' className='tl'><Link href={url}>{build.name}</Link></td>,
|
<td key='s' className='tl'><Link href={url}>{build.name}</Link></td>,
|
||||||
<td key='bn' className='tl'><Link href={url}>{build.buildName}</Link></td>
|
<td key='bn' className='tl'><Link href={url}>{build.buildName}</Link></td>
|
||||||
|
|||||||
@@ -29,12 +29,14 @@ export default class Modification extends TranslatedComponent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update modification given a value.
|
* Update modification given a value.
|
||||||
* @param {Number} value The value to set
|
* @param {Number} value The value to set. This comes in as a string and must be stored in state as a string,
|
||||||
|
* because it needs to allow illegal 'numbers' ('-', '1.', etc) when the user is typing
|
||||||
|
* in a value by hand
|
||||||
*/
|
*/
|
||||||
_updateValue(value) {
|
_updateValue(value) {
|
||||||
const name = this.props.name;
|
const name = this.props.name;
|
||||||
|
|
||||||
let scaledValue = Math.floor(Number(value) * 100);
|
let scaledValue = Math.round(Number(value) * 100);
|
||||||
// Limit to +1000% / -100%
|
// Limit to +1000% / -100%
|
||||||
if (scaledValue > 100000) {
|
if (scaledValue > 100000) {
|
||||||
scaledValue = 100000;
|
scaledValue = 100000;
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ export default class OutfittingPage extends Page {
|
|||||||
<div id='overview'>
|
<div id='overview'>
|
||||||
<h1>{ship.name}</h1>
|
<h1>{ship.name}</h1>
|
||||||
<div id='build'>
|
<div id='build'>
|
||||||
<input value={newBuildName} onChange={this._buildNameChange} placeholder={translate('Enter Name')} maxLength={50} />
|
<input value={newBuildName || ''} onChange={this._buildNameChange} placeholder={translate('Enter Name')} maxLength={50} />
|
||||||
<button onClick={canSave && this._saveBuild} disabled={!canSave} onMouseOver={termtip.bind(null, 'save')} onMouseOut={hide}>
|
<button onClick={canSave && this._saveBuild} disabled={!canSave} onMouseOver={termtip.bind(null, 'save')} onMouseOut={hide}>
|
||||||
<FloppyDisk className='lg' />
|
<FloppyDisk className='lg' />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Ship from './Ship';
|
|||||||
import * as ModuleUtils from './ModuleUtils';
|
import * as ModuleUtils from './ModuleUtils';
|
||||||
import * as Utils from '../utils/UtilityFunctions';
|
import * as Utils from '../utils/UtilityFunctions';
|
||||||
import LZString from 'lz-string';
|
import LZString from 'lz-string';
|
||||||
|
import { outfitURL } from '../utils/UrlGenerators';
|
||||||
|
|
||||||
const STANDARD = ['powerPlant', 'thrusters', 'frameShiftDrive', 'lifeSupport', 'powerDistributor', 'sensors', 'fuelTank'];
|
const STANDARD = ['powerPlant', 'thrusters', 'frameShiftDrive', 'lifeSupport', 'powerDistributor', 'sensors', 'fuelTank'];
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ export function toDetailedBuild(buildName, ship) {
|
|||||||
ship: ship.name,
|
ship: ship.name,
|
||||||
references: [{
|
references: [{
|
||||||
name: 'Coriolis.io',
|
name: 'Coriolis.io',
|
||||||
url: `https://coriolis.edcd.io/outfit/${ship.id}/${code}?bn=${encodeURIComponent(buildName)}`,
|
url: 'https://coriolis.edcd.io' + outfitURL(ship.id, code, buildName),
|
||||||
code,
|
code,
|
||||||
shipId: ship.id
|
shipId: ship.id
|
||||||
}],
|
}],
|
||||||
|
|||||||
@@ -6,15 +6,18 @@
|
|||||||
* @return {String} URL
|
* @return {String} URL
|
||||||
*/
|
*/
|
||||||
export function outfitURL(shipId, code, buildName) {
|
export function outfitURL(shipId, code, buildName) {
|
||||||
let parts = ['/outfit/', shipId];
|
let path = '/outfit/' + shipId;
|
||||||
|
|
||||||
|
let sepChar = '?';
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
parts.push('/', code);
|
path = path + sepChar + 'code=' + encodeURIComponent(code);
|
||||||
|
sepChar = '&';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildName) {
|
if (buildName) {
|
||||||
parts.push('?bn=', encodeURIComponent(buildName));
|
path = path + sepChar + 'bn=' + encodeURIComponent(buildName);
|
||||||
}
|
}
|
||||||
return parts.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user