This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- init does what you might think it does, it initializes the applicaiton. | |
-- In this app, I need to fetch the list of tags when the page loads so | |
-- the user has some navigation to work with so I make the call to the | |
-- httpCommand function. | |
init : ( Model, Cmd Msg ) | |
init = | |
let model = { categories = [] | |
, errorMsg = Nothing | |
, selectedTag = "All" | |
, summaries = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update msg model = | |
if msg.operation == "SELECT_TAG" then | |
{ model | selectedTag = msg.data } | |
else | |
model | |
main = | |
Html.beginnerProgram | |
{ model = initialModel | |
, view = view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
viewTag selectedTag tag = | |
div | |
[ classList [ ("tag",True), ( "selected", selectedTag == tag ) ] | |
, onClick { operation = "SELECT_TAG", data = tag } | |
] | |
[text tag] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialModel = | |
{ tags = ["All" | |
, "9/11" | |
, "Deep State" | |
, "New World Order" | |
, "UFO" | |
, "Untagged"] | |
, selectedTag = "All"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view model = | |
div [ class "container-fluid" ] | |
[ div [ class "row" ] | |
[ | |
div [ class "col-md-2 d-none d-md-block bg-light sidebar"] | |
[text "This is where the nav will go"] | |
,div [ class "col-md-9 ml-sm-auto col-lg-10 px-4" ] | |
[ div [ class "content-heading" ] [ h2 [] [ text "Selected Tag"]] | |
, div [] [ text "this is where the summaries will be displayed"] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helloworld2 exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
view = | |
div [ class "container-fluid" ] | |
[ div [ class "row"] | |
[ text "Do you know about Area 52? BTW, I'm now in a child div!"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Conspiracies exposing (..) | |
import Html exposing (..) | |
main = | |
text "Do you know about Area 52?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body > | |
<div id="elm-area"></div> | |
<script src="helloworld.js"></script> | |
<script> | |
Elm.Conspiracies.embed(document.getElementById("elm-area")); | |
</script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cargo build | |
Compiling conspiracies v0.0.1 (file:///<path to your code>/conspiracies_api) | |
error[E0412]: cannot find type `WikiPage` in this scope | |
--> src/main.rs:56:46 | |
| | |
56 | fn get_page(self, title: String) -> Result<WikiPage, wikipedia::Error> { | |
| ^^^^^^^^ not found in this scope | |
error[E0422]: cannot find struct, variant or union type `WikiPage` in this scope | |
--> src/main.rs:69:16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
std::env::set_var("RUST_LOG", "actix_web=info"); | |
env_logger::init(); | |
...setting up the actix system... | |
// Start http server | |
HttpServer::new(move || { | |
App::with_state(State{db: addr.clone()}) | |
.middleware(Logger::default()) |