Skip to content

Commit

Permalink
feat: reduce number of steps needed to get going for local development (
Browse files Browse the repository at this point in the history
#454)

* feat: reduce number of steps to get going for local development

* fix: set default sync server in SNJS

* chore: keep --force in submodules command
  • Loading branch information
arielsvg authored Sep 2, 2020
1 parent 6a1c10d commit 57aa942
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ SF_DEFAULT_SERVER=http://localhost:3000

# Datadog
DATADOG_ENABLED=false

# Development options
DEV_DEFAULT_SYNC_SERVER=https://sync.standardnotes.org
DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html
DEV_BATCH_MANAGER_LOCATION=public/extensions/batch-manager/dist/index.min.html
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

dump.rdb

index.html

# Ignore compiled assets
/public/assets

Expand All @@ -42,4 +40,4 @@ index.html
# Generated Files
/dist/javascripts
/dist/stylesheets
/dist/fonts
/dist/fonts
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ This repo contains the core code used in the web app, as well as the Electron-ba
**Instructions:**

1. Clone the repo
1. `bundle install`
1. `npm install`
1. `bundle exec rails assets:precompile`
1. `cp index.html.sample index.html`
1. `npm run setup`
1. `npm start`

Then open your browser to `http://localhost:3001`.
Expand Down
11 changes: 9 additions & 2 deletions app/assets/javascripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,26 @@ import { isDev } from './utils';
import { Bridge, BrowserBridge } from './services/bridge';

if (__WEB__) {
startApplication(new BrowserBridge());
startApplication(
(window as any)._default_sync_server,
new BrowserBridge()
);
} else {
(window as any).startApplication = startApplication;
}

function startApplication(bridge: Bridge) {
function startApplication(
defaultSyncServerHost: string,
bridge: Bridge
) {
angular.module('app', ['ngSanitize']);

// Config
angular
.module('app')
.config(configRoutes)
.constant('bridge', bridge)
.constant('defaultSyncServerHost', defaultSyncServerHost)
.constant('appVersion', __VERSION__);

// Controllers
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/ui_models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class WebApplication extends SNApplication {
$timeout: ng.ITimeoutService,
scope: ng.IScope,
onDeinit: (app: WebApplication) => void,
defaultSyncServerHost: string,
bridge: Bridge,
) {
const namespace = '';
Expand All @@ -73,6 +74,7 @@ export class WebApplication extends SNApplication {
namespace,
undefined,
undefined,
defaultSyncServerHost
);
this.$compile = $compile;
this.scope = scope;
Expand Down
6 changes: 4 additions & 2 deletions app/assets/javascripts/ui_models/application_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class ApplicationGroup {
$compile: ng.ICompileService,
$rootScope: ng.IRootScopeService,
$timeout: ng.ITimeoutService,
private bridge: Bridge
private defaultSyncServerHost: string,
private bridge: Bridge,
) {
this.$compile = $compile;
this.$timeout = $timeout;
Expand Down Expand Up @@ -71,7 +72,8 @@ export class ApplicationGroup {
this.$timeout,
scope,
this.onApplicationDeinit,
this.bridge
this.defaultSyncServerHost,
this.bridge,
);
const appState = new AppState(
this.$rootScope,
Expand Down
19 changes: 9 additions & 10 deletions index.html.sample → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@
<meta ng-bind="title" content="Standard Notes" name="application-name" />

<title>Dev · Notes · Standard Notes</title>
</head>

<body
data-default-sync-server="<%= env.DEV_DEFAULT_SYNC_SERVER %>"
data-extensions-manager-location="<%= env.DEV_EXTENSIONS_MANAGER_LOCATION %>"
data-batch-manager-location="<%= env.DEV_BATCH_MANAGER_LOCATION %>"
>
<script>
window._default_sync_server = "https://sync.standardnotes.org";
window._extensions_manager_location = "public/extensions/extensions-manager/dist/index.html";
window._batch_manager_location = "public/extensions/batch-manager/dist/index.min.html";
window._default_sync_server = document.body.dataset.defaultSyncServer || "https://sync.standardnotes.org";
window._extensions_manager_location = document.body.dataset.extensionsManagerLocation || "public/extensions/extensions-manager/dist/index.html";
window._batch_manager_location = document.body.dataset.batchManagerLocation || "public/extensions/batch-manager/dist/index.min.html";
</script>

<script src="/dist/javascripts/app.js"></script>
<link rel="stylesheet" media="all" href="/dist/stylesheets/app.css" debug="false" />

</head>

<body>
<application-group-view />
</body>

Expand Down
Loading

0 comments on commit 57aa942

Please sign in to comment.