-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add modem to handle multipages
Signed-off-by: Guillaume Hivert <[email protected]>
- Loading branch information
Showing
11 changed files
with
133 additions
and
38 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import data/search_result.{type SearchResults} | ||
import frontend/router | ||
import lustre_http as http | ||
|
||
pub type Msg { | ||
None | ||
SubmitSearch | ||
SearchResults(Result(SearchResults, http.HttpError)) | ||
SearchResults(input: String, result: Result(SearchResults, http.HttpError)) | ||
UpdateInput(String) | ||
Reset | ||
ScrollTo(String) | ||
OnRouteChange(router.Route) | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub const internal_error = "/images/internal_error.png" | ||
|
||
pub const shadow_lucy = "/images/shadow_lucy.png" | ||
|
||
pub const loading = "/images/loading.svg" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import gleam/list | ||
import gleam/option | ||
import gleam/result | ||
import gleam/uri.{type Uri} | ||
|
||
pub type Route { | ||
Home | ||
Search(query: String) | ||
} | ||
|
||
pub fn parse_uri(uri: Uri) -> Route { | ||
case uri.path_segments(uri.path) { | ||
["search"] -> handle_search_path(uri) | ||
_ -> Home | ||
} | ||
} | ||
|
||
fn handle_search_path(uri: Uri) { | ||
uri.query | ||
|> option.map(uri.parse_query) | ||
|> option.then(fn(query_params) { | ||
query_params | ||
|> result.unwrap([]) | ||
|> list.key_find("q") | ||
|> option.from_result() | ||
}) | ||
|> option.map(Search) | ||
|> option.unwrap(Home) | ||
} |
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
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
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
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