Skip to content

Commit 9b7c76b

Browse files
authored
feat: new setup to import projects (#95)
* wip * mostly working * cleanup * hide hidden projects * disable example API for non-lean files * fix env vars * fix build * some adjustments from live deployment * link
1 parent c89e688 commit 9b7c76b

27 files changed

+371
-204
lines changed

Projects/MathlibDemo/lake-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"subDir": null,
77
"scope": "leanprover-community",
8-
"rev": "55aa437fb40b168305405301f173cf0cb2adfe94",
8+
"rev": "be0a10d1f1d5c9434f47080fa0e2aa48b678ab3a",
99
"name": "mathlib",
1010
"manifestFile": "lake-manifest.json",
1111
"inputRev": "master",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Latest Mathlib",
3+
"default": true,
4+
"hidden": false,
5+
"examples": [
6+
{ "file": "MathlibDemo/Bijection.lean", "name": "Bijection" },
7+
{ "file": "MathlibDemo/Logic.lean", "name": "Logic" },
8+
{ "file": "MathlibDemo/Ring.lean", "name": "Ring" },
9+
{ "file": "MathlibDemo/Rational.lean", "name": "Rational" }
10+
]
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Stable Lean",
3+
"hidden": false
4+
}

client/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { LeanWebConfig } from "./src/api/config-types";
2+
3+
export const lean4webConfig: LeanWebConfig = {
4+
serverCountry: null,
5+
contactDetails: null,
6+
impressum: null,
7+
};

client/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Menu } from './navigation/Navigation'
1717
import { mobileAtom, settingsAtom } from './settings/settings-atoms'
1818
import { lightThemes } from './settings/settings-types'
1919
import { freshlyImportedCodeAtom } from './store/import-atoms'
20-
import { projectAtom } from './store/project-atoms'
20+
import { currentProjectAtom } from './store/project-atoms'
2121
import { screenWidthAtom } from './store/window-atoms'
2222
import { save } from './utils/SaveToFile'
2323

@@ -35,7 +35,7 @@ function App() {
3535
const [settings] = useAtom(settingsAtom)
3636
const [mobile] = useAtom(mobileAtom)
3737
const [, setScreenWidth] = useAtom(screenWidthAtom)
38-
const [project] = useAtom(projectAtom)
38+
const [project] = useAtom(currentProjectAtom)
3939
const [code, setCode] = useAtom(codeAtom)
4040
const [freshlyImportedCode] = useAtom(freshlyImportedCodeAtom)
4141

@@ -76,7 +76,7 @@ function App() {
7676
(window.location.protocol === 'https:' ? 'wss://' : 'ws://') +
7777
window.location.host +
7878
'/websocket/' +
79-
project
79+
project.folder
8080
console.log(`[Lean4web] Socket url is ${socketUrl}`)
8181
var _options: LeanMonacoOptions = {
8282
websocket: { url: socketUrl },
@@ -108,7 +108,7 @@ function App() {
108108

109109
// Setting up the editor and infoview
110110
useEffect(() => {
111-
if (project === undefined) return
111+
if (!project) return
112112
console.debug('[Lean4web] Restarting editor')
113113
var _leanMonaco = new LeanMonaco()
114114
var leanMonacoEditor = new LeanMonacoEditor()
@@ -118,7 +118,7 @@ function App() {
118118
await _leanMonaco.start(options)
119119
await leanMonacoEditor.start(
120120
editorRef.current!,
121-
path.join(project, `${project}.lean`),
121+
path.join(project.folder, `${project.folder}.lean`),
122122
code ?? '',
123123
)
124124

client/src/Popups/Impressum.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import lean4webConfig from '../config/config'
1+
import { lean4webConfig } from '../../config'
22
import { Popup } from '../navigation/Popup'
33

44
/** The popup with the privacy policy. */

client/src/Popups/PrivacyPolicy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import lean4webConfig from '../config/config'
1+
import { lean4webConfig } from '../../config'
22
import { Popup } from '../navigation/Popup'
33

44
/** The popup with the privacy policy. */

client/src/api/config-types.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { JSX } from 'react'
2+
3+
export type LeanWebConfig = {
4+
/** Where the server is located. Use `null` to not display this information. */
5+
serverCountry: string | null
6+
/** Contact details of the server maintainer. Used in Privacy Policy and Impressum.
7+
* Use `null` to not display this information.
8+
* Note: This will be embedded inside a `<p>` tag! (example: `<>Hans Muster<br />hans@nowhere.com</>`)
9+
*/
10+
contactDetails: JSX.Element | null
11+
/** Additional legal information shown in impressum alongside the contact details.
12+
* Use `null` to not display this information.
13+
* (example: `<><p>vat number: 000</p><>`)
14+
*/
15+
impressum: JSX.Element | null
16+
}

0 commit comments

Comments
 (0)