Fix merge conflicts

This commit is contained in:
Marquis Kurt 2019-05-11 12:59:36 -04:00
commit deecd99845
11 changed files with 77 additions and 106 deletions

View File

@ -1,49 +0,0 @@
# Configuring Hyperspace
Hyperspace 1.0 comes with a new configuration file app providers can use to create a custom experience relatively easy. This is inspired from the way the [Riot](https://github.com/vector-im/riot-web) project handles configurations for their app. The following fields should be in the `config.json` folder at the root of the Hyperspace installation.
> Note: `config.json` can only control and modify so much with the app. If you want further customizations like custom themes, new panels, etc., it is recommended that you fork Hyperspace and work with it that way.
- `version`: The app's version using semantic versioning. This can be used to differentiate between versions of the main Hyperspace app or the custom deployment.
- `branding`: The custom branding for Hyperspace.
- `name`: The name for the brand/app. Affects title bar, about screens, and main interface by replacing the "Hyperspace" text.
- `logo`: The filepath of the brand's logo, relative to the deployment folder. Can be a relative path (`brand/logo.png`) or a URL (`https://www.test.com/brands/logo-hs.png`).
- `background`: The background used on the login page. Can be a relative path (`brand/bg.png`) or a URL (`https://www.test.com/brands/bg-hs.png`)
- `developer`: Whether the version is a developer version or should be put in developer mode. Used to signify unstable releases with new features to play around with.
- `federated`: Whether Hyperspace should enable federating features in its interface for Mastodon. Disabling federation disables the public timeline.
- `registration`: Information regarding registration of accounts.
- `defaultInstance`: The host name of the instance to default to when making accounts. Affects "well-known" sign-in and 'Create account' buttons
- `admin`: Information about the app provider/administrator:
- `name`: The name of the app provider
- `account`: The Account ID of the app provider on Mastodon, in-instance or not
- `license`: Licensing information about the app. Will default to Apache 2.0 if not listed (the standard license for Hyperspace source code).
- `name`: The name of the license.
- `url`: The link to the license for reviewing.
- `repository`: The URL to the source code, if possible.
## Example Config File
```json
{
"version": "1.0.0beta1",
"branding": {
"name": "Hyperspace",
"logo": "logo.svg",
"background": "background.png"
},
"developer": "true",
"federated": "true",
"registration": {
"defaultInstance": "mastodon.social"
},
"admin": {
"name": "Eugen",
"account": "1"
},
"license": {
"name": "Apache 2.0 License",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
},
"repository": "https://github.com/hyperspacedev/hyperspace"
}
```

View File

@ -15,7 +15,7 @@ The 1.0 redesign of Hyperspace acts differently from the current classic version
- **Pages over panels**. Hyperspace 1.0 uses `react-router-dom` to link components of the app via URLs instead of individual components. This means that one could visit the corresponding URL instead of needing to open a set of panels or buttons to do so.
- **Material design**. Hyperspace 1.0 uses Material Design to create a UI that scales across device types. The library used for the UI, `material-ui`, natively supports a dark mode and themes, making Hyperspace 1.0 more customizable in nature.
- **Less intrusive by nature.** Hyperspace 1.0 pushes notifications when the window isn't in focus versus all the time, and the snackbar (toast) notifications are displayed more often when something is happening or when an error occurs. Timelines also no longer keep pushing posts during streaming, letting anyone read the timeline and still be able to get updates with a non-intrusive `View (x) new posts` chip at the top.
- **Configurable at every level.** Hyperspace 1.0 allows anyone to customize their theme and settings to however they like, and admins can customize Hyperspace further with branding, federation support, registration URLs, and more (done via `config.json`). [Learn more ›](CONFIG.md)
- **Configurable at every level.** Hyperspace 1.0 allows anyone to customize their theme and settings to however they like, and admins can customize Hyperspace further with branding, federation support, registration URLs, and more (done via `config.json`). [Learn more ›](https://hyperspace.marquiskurt.net/docs/configure-hyperspace)
This is a growing list and new things will be added over time.

View File

@ -6,8 +6,12 @@
"logo": "logo.svg",
"background": "background.png"
},
"developer": "true",
"federated": "true",
"developer": true,
"federation": {
"universalLogin": true,
"allowPublicPosts": true,
"enablePublicTimeline": true
},
"registration": {
"defaultInstance": "mastodon.social"
},

View File

@ -21,6 +21,7 @@ import { Notification } from '../../types/Notification';
import {sendNotificationRequest} from '../../utilities/notifications';
import {withSnackbar} from 'notistack';
import { getConfig, getUserDefaultBool } from '../../utilities/settings';
import { Config } from '../../types/Config';
interface IAppLayoutState {
acctMenuOpen: boolean;
@ -70,12 +71,15 @@ export class AppLayout extends Component<any, IAppLayoutState> {
})
}
getConfig().then((config: any) => {
this.setState({
enableFederation: config.federated === "true",
brandName: config.branding? config.branding.name: "Hyperspace",
developerMode: config.developer === "true"
});
getConfig().then((result: any) => {
if (result !== undefined) {
let config: Config = result;
this.setState({
enableFederation: config.federation.enablePublicTimeline,
brandName: config.branding? config.branding.name: "Hyperspace",
developerMode: config.developer
});
}
})
this.streamNotifications()

View File

@ -1,22 +0,0 @@
import {License} from '../types/Config';
export interface Config {
version: string;
location: string;
branding?: {
name?: string;
logo?: string;
background?: string;
};
developer?: string;
federated?: string;
registration?: {
defaultInstance?: string;
};
admin?: {
name?: string;
account?: string;
};
license: License;
respository?: string;
}

View File

@ -28,6 +28,8 @@ import NotesIcon from '@material-ui/icons/Notes';
import CodeIcon from '@material-ui/icons/Code';
import TicketAccountIcon from 'mdi-material-ui/TicketAccount';
import MastodonIcon from 'mdi-material-ui/Mastodon';
import EditIcon from '@material-ui/icons/Edit';
import VpnKeyIcon from '@material-ui/icons/VpnKey';
import {styles} from './PageLayout.styles';
import {Instance} from '../types/Instance';
@ -35,11 +37,12 @@ import {LinkableIconButton, LinkableAvatar} from '../interfaces/overrides';
import Mastodon from 'megalodon';
import { UAccount } from '../types/Account';
import { getConfig } from '../utilities/settings';
import { License } from '../types/Config';
import { License, Federation } from '../types/Config';
interface IAboutPageState {
instance?: Instance;
federated?: boolean;
federation?: Federation;
developer?: boolean;
hyperspaceAdmin?: UAccount;
hyperspaceAdminName?: string;
@ -80,7 +83,7 @@ class AboutPage extends Component<any, IAboutPageState> {
this.setState({
hyperspaceAdmin: account,
hyperspaceAdminName: config.admin.name,
federated: config.federated? config.federated === "true": false,
federation: config.federation,
developer: config.developer? config.developer === "true": false,
versionNumber: config.version,
brandName: config.branding? config.branding.name: "Hyperspace",
@ -278,7 +281,23 @@ class AboutPage extends Component<any, IAboutPageState> {
<NetworkCheckIcon/>
</Avatar>
</ListItemAvatar>
<ListItemText primary="Federation status" secondary={`This instance of ${this.state? this.state.brandName: "Hyperspace"} ${this.state? this.state.federated? "supports": "doesn't support": "might support"} federation.`}/>
<ListItemText primary="General federation" secondary={this.state.federation && this.state.federation.enablePublicTimeline? "This instance is federated.": "This instance is not federated."}/>
</ListItem>
<ListItem>
<ListItemAvatar>
<Avatar>
<VpnKeyIcon/>
</Avatar>
</ListItemAvatar>
<ListItemText primary="Universal login" secondary={this.state.federation && this.state.federation.universalLogin? "This instance supports universal login.": "This instance does not support universal login."}/>
</ListItem>
<ListItem>
<ListItemAvatar>
<Avatar>
<EditIcon/>
</Avatar>
</ListItemAvatar>
<ListItemText primary="Public posting" secondary={this.state.federation && this.state.federation.allowPublicPosts? "This instance allows posting publicly.": "This instance does not allow posting publicly."}/>
</ListItem>
</List>
</Paper>

View File

@ -65,7 +65,7 @@ class Composer extends Component<any, IComposerState> {
let text = state.acct? `@${state.acct}: `: '';
getConfig().then((config: any) => {
this.setState({
federated: config.federated === "true",
federated: config.federation.allowPublicPosts,
reply: state.reply,
acct: state.acct,
visibility: state.visibility,

View File

@ -43,6 +43,7 @@ import NotificationsIcon from '@material-ui/icons/Notifications';
import BellAlertIcon from 'mdi-material-ui/BellAlert';
import RefreshIcon from '@material-ui/icons/Refresh';
import UndoIcon from '@material-ui/icons/Undo';
import { Config } from '../types/Config';
interface ISettingsState {
darkModeEnabled: boolean;
@ -104,8 +105,12 @@ class SettingsPage extends Component<any, ISettingsState> {
}
getFederatedStatus() {
getConfig().then((config: any) => {
this.setState({ federated: config.federated === "true" });
getConfig().then((result: any) => {
if (result !== undefined) {
let config: Config = result;
console.log(config.federation.allowPublicPosts === false)
this.setState({ federated: config.federation.allowPublicPosts });
}
})
}

View File

@ -8,6 +8,7 @@ import {parseUrl} from 'query-string';
import { getConfig } from '../utilities/settings';
import axios from 'axios';
import {withSnackbar, withSnackbarProps} from 'notistack';
import { Config } from '../types/Config';
interface IWelcomeProps extends withSnackbarProps {
classes: any;
@ -59,22 +60,25 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
}
getConfig().then((result: any) => {
if (result.location === "dynamic") {
console.warn("Recirect URI is set to dyanmic, which may affect how sign-in works for some users. Careful!");
} else if (result.location === "desktop") {
console.warn("Recirect URI is set to desktop, which may affect how sign-in works for some users. This will use https://localhost; careful!");
}
this.setState({
logoUrl: result.branding? result.branding.logo: "logo.png",
backgroundUrl: result.branding? result.branding.background: "background.png",
brandName: result.branding? result.branding.name: "Hyperspace",
registerBase: result.registration? result.registration.defaultInstance: "",
federates: result.federated? result.federated === "true": true,
license: result.license.url,
repo: result.repository,
defaultRedirectAddress: getRedirectAddress(result.location),
version: result.version
});
if (result !== undefined) {
let config: Config = result;
if (result.location === "dynamic") {
console.warn("Recirect URI is set to dyanmic, which may affect how sign-in works for some users. Careful!");
} else if (result.location === "desktop") {
console.warn("Recirect URI is set to desktop, which may affect how sign-in works for some users. This will use https://localhost; careful!");
}
this.setState({
logoUrl: config.branding? result.branding.logo: "logo.png",
backgroundUrl: config.branding? result.branding.background: "background.png",
brandName: config.branding? result.branding.name: "Hyperspace",
registerBase: config.registration? result.registration.defaultInstance: "",
federates: config.federation.universalLogin,
license: config.license.url,
repo: config.repository,
defaultRedirectAddress: config.location != "dynamic"? config.location: `https://${window.location.host}`,
version: config.version
});
}
}).catch(() => {
console.error('config.json is missing. If you want to customize Hyperspace, please include config.json');
})

View File

@ -6,8 +6,8 @@ export type Config = {
logo?: string;
background?: string;
};
developer?: string;
federated?: string;
developer?: boolean;
federation: Federation;
registration?: {
defaultInstance?: string;
};
@ -16,10 +16,16 @@ export type Config = {
account?: string;
};
license: License;
respository?: string;
repository?: string;
}
export type License = {
name: string;
url: string;
}
export type Federation = {
universalLogin: boolean;
allowPublicPosts: boolean;
enablePublicTimeline: boolean;
}

View File

@ -116,7 +116,7 @@ export function createUserDefaults() {
* Gets the configuration data from `config.json`
* @returns The Promise data from getting the config.
*/
export async function getConfig() {
export async function getConfig(): Promise<Config | undefined> {
try {
const resp = await axios.get('config.json');
let config: Config = resp.data;