mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-09-11 09:05:28 +03:00
elm-app-gen
This commit is contained in:
commit
71dd7cbabe
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
elm-stuff/
|
||||
dist/
|
||||
.cache/
|
69
README.md
Normal file
69
README.md
Normal file
@ -0,0 +1,69 @@
|
||||
# elm-markup-pages
|
||||
|
||||
Static site generator for elm-markup.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
`npm install`
|
||||
|
||||
### Running Locally
|
||||
|
||||
`npm start`
|
||||
|
||||
Will compile your app and serve it from http://localhost:1234/
|
||||
Changes to your source code will trigger a hot-reload in the browser, which
|
||||
will also show compiler errors on build failures.
|
||||
|
||||
### Running Tests
|
||||
|
||||
`npm test`
|
||||
|
||||
or
|
||||
|
||||
`npm run autotest`
|
||||
|
||||
To re-run tests when files change.
|
||||
|
||||
### Production build
|
||||
|
||||
`npm run build`
|
||||
|
||||
Will generate a production-ready build of your app in the `dist` folder.
|
||||
|
||||
### Elm Commands
|
||||
|
||||
Elm binaries can be found in `node_modules/.bin`. They can be run from within
|
||||
your project via `npx`
|
||||
|
||||
|
||||
To install new Elm packages, run:
|
||||
|
||||
`npx elm install <packageName>`
|
||||
|
||||
## Libraries & Tools
|
||||
|
||||
These are the main libraries and tools used to build elm-markup-pages. If you're not
|
||||
sure how something works, getting more familiar with these might help.
|
||||
|
||||
### [Elm](https://elm-lang.org)
|
||||
|
||||
Elm is a delightful language for creating reliable webapps. It guarantees no
|
||||
runtime exceptions, and provides excellent performance. If you're not familiar
|
||||
with it, [the official guide](https://guide.elm-lang.org) is a great place to get
|
||||
started, and the folks on [Slack](https://elmlang.herokuapp.com) and
|
||||
[Discourse](https://discourse.elm-lang.org) are friendly and helpful if you get
|
||||
stuck.
|
||||
|
||||
### [Elm Test](https://package.elm-lang.org/packages/elm-exploration/test/latest)
|
||||
|
||||
This is the standard testing library for Elm. In addition to being useful for
|
||||
traditional fixed-input unit tests, it also supports property-based testing
|
||||
where random data is used to validate behavior over a large input space. It's
|
||||
really useful!
|
||||
|
||||
### [Parcel](https://parceljs.org)
|
||||
|
||||
Parcel build and bundles the application's assets into individual HTML, CSS, and
|
||||
JavaScript files. It also runs the live-server used during development.
|
27
elm.json
Normal file
27
elm.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "elm-markup-pages",
|
||||
"type": "application",
|
||||
"source-directories": ["src"],
|
||||
"elm-version": "0.19.0",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.1",
|
||||
"elm/core": "1.0.2",
|
||||
"elm/html": "1.0.0",
|
||||
"elm/url": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.0.0",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {
|
||||
"elm-explorations/test": "1.2.1"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/random": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
8370
package-lock.json
generated
Normal file
8370
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
package.json
Normal file
21
package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "elm-markup-pages",
|
||||
"version": "1.0.0",
|
||||
"description": "Static site generator for elm-markup.",
|
||||
"scripts": {
|
||||
"start": "parcel src/index.html",
|
||||
"build": "rm -r dist && parcel build src/index.html --public-url ./",
|
||||
"test": "elm-test",
|
||||
"autotest": "elm-test --watch"
|
||||
},
|
||||
"author": "Dillon Kearns",
|
||||
"license": "BSD-3",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"elm": "^0.19.0-no-deps",
|
||||
"elm-hot": "^1.0.1",
|
||||
"elm-test": "^0.19.0-rev6",
|
||||
"node-elm-compiler": "^5.0.3",
|
||||
"parcel-bundler": "^1.12.0"
|
||||
}
|
||||
}
|
99
src/Main.elm
Normal file
99
src/Main.elm
Normal file
@ -0,0 +1,99 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import Browser
|
||||
import Browser.Navigation as Nav
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Url
|
||||
|
||||
|
||||
|
||||
-- MAIN
|
||||
|
||||
|
||||
main : Program () Model Msg
|
||||
main =
|
||||
Browser.application
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
, onUrlChange = UrlChanged
|
||||
, onUrlRequest = LinkClicked
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ key : Nav.Key
|
||||
, url : Url.Url
|
||||
}
|
||||
|
||||
|
||||
init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||
init flags url key =
|
||||
( Model key url, Cmd.none )
|
||||
|
||||
|
||||
|
||||
-- UPDATE
|
||||
|
||||
|
||||
type Msg
|
||||
= LinkClicked Browser.UrlRequest
|
||||
| UrlChanged Url.Url
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
LinkClicked urlRequest ->
|
||||
case urlRequest of
|
||||
Browser.Internal url ->
|
||||
( model, Nav.pushUrl model.key (Url.toString url) )
|
||||
|
||||
Browser.External href ->
|
||||
( model, Nav.load href )
|
||||
|
||||
UrlChanged url ->
|
||||
( { model | url = url }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
|
||||
-- SUBSCRIPTIONS
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ =
|
||||
Sub.none
|
||||
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Model -> Browser.Document Msg
|
||||
view model =
|
||||
{ title = "URL Interceptor"
|
||||
, body =
|
||||
[ text "The current URL is: "
|
||||
, b [] [ text (Url.toString model.url) ]
|
||||
, ul []
|
||||
[ viewLink "/home"
|
||||
, viewLink "/profile"
|
||||
, viewLink "/reviews/the-century-of-the-self"
|
||||
, viewLink "/reviews/public-opinion"
|
||||
, viewLink "/reviews/shah-of-shahs"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
viewLink : String -> Html msg
|
||||
viewLink path =
|
||||
li [] [ a [ href path ] [ text path ] ]
|
3
src/css/style.css
Normal file
3
src/css/style.css
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
font-family: "sans-serif";
|
||||
}
|
13
src/index.html
Normal file
13
src/index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>elm-markup-pages</title>
|
||||
<link rel="stylesheet" href="./css/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
5
src/js/app.js
Normal file
5
src/js/app.js
Normal file
@ -0,0 +1,5 @@
|
||||
import { Elm } from "../Main.elm";
|
||||
|
||||
Elm.Main.init({
|
||||
node: document.getElementById("app")
|
||||
});
|
10
tests/Example.elm
Normal file
10
tests/Example.elm
Normal file
@ -0,0 +1,10 @@
|
||||
module Example exposing (..)
|
||||
|
||||
import Expect exposing (Expectation)
|
||||
import Fuzz exposing (Fuzzer, int, list, string)
|
||||
import Test exposing (..)
|
||||
|
||||
|
||||
suite : Test
|
||||
suite =
|
||||
todo "Implement our first test. See https://package.elm-lang.org/packages/elm-explorations/test/latest for how to do this!"
|
Loading…
Reference in New Issue
Block a user