Browse Source

add record_store kind and fmt

master
zapashcanon 2 months ago
parent
commit
bd7c49d752
Signed by: zapashcanon GPG Key ID: 8981C3C62D1D28F1
  1. 2
      .ocamlformat
  2. 2
      src/places.ml
  3. 87
      src/places_js.ml

2
.ocamlformat

@ -1,4 +1,4 @@
version=0.26.1
version=0.26.2
assignment-operator=end-line
break-cases=fit
break-fun-decl=wrap

2
src/places.ml

@ -42,6 +42,8 @@ let controller request =
; txt request ~fr:"Ferme" ~en:"Farm"
; mk_opt "include_walk"
; txt request ~fr:"Promenade" ~en:"Esplanade"
; mk_opt "include_record_store"
; txt request ~fr:"Disquaire" ~en:"Record Store"
]
in
let body = options @ [ div ~a:[ a_id "map" ] [] ] in

87
src/places_js.ml

@ -46,6 +46,7 @@ type kind =
; walk : bool
; farm : bool
; cheese_shop : bool
; record_shop : bool
}
let empty_kind =
@ -65,6 +66,7 @@ let empty_kind =
; walk = false
; farm = false
; cheese_shop = false
; record_shop = false
}
let kind_of_dir dir =
@ -76,25 +78,26 @@ let kind_of_dir dir =
let kinds = List.map (Query.get_param_exn 0) kinds in
List.fold_left
(fun kind -> function
| "bar" -> { kind with bar = true }
| "restaurant" -> { kind with restaurant = true }
| "poetry" -> { kind with poetry = true }
| "union" -> { kind with union = true }
| "concert" -> { kind with concert = true }
| "club" -> { kind with club = true }
| "exhibition" -> { kind with exhibition = true }
| "squat" -> { kind with squat = true }
| "hackerspace" -> { kind with hackerspace = true }
| "garden" -> { kind with garden = true }
| "teahouse" -> { kind with teahouse = true }
| "hammam" -> { kind with hammam = true }
| "artisanry" -> { kind with artisanry = true }
| "walk" -> { kind with walk = true }
| "farm" -> { kind with farm = true }
| "cheese_shop" -> { kind with cheese_shop = true }
| s ->
Format.eprintf "unhandled place kind: %S" s;
assert false )
| "bar" -> { kind with bar = true }
| "restaurant" -> { kind with restaurant = true }
| "poetry" -> { kind with poetry = true }
| "union" -> { kind with union = true }
| "concert" -> { kind with concert = true }
| "club" -> { kind with club = true }
| "exhibition" -> { kind with exhibition = true }
| "squat" -> { kind with squat = true }
| "hackerspace" -> { kind with hackerspace = true }
| "garden" -> { kind with garden = true }
| "teahouse" -> { kind with teahouse = true }
| "hammam" -> { kind with hammam = true }
| "artisanry" -> { kind with artisanry = true }
| "walk" -> { kind with walk = true }
| "farm" -> { kind with farm = true }
| "cheese_shop" -> { kind with cheese_shop = true }
| "record_shop" -> { kind with record_shop = true }
| s ->
Format.eprintf "unhandled place kind: %S" s;
assert false )
empty_kind kinds
type marker =
@ -182,26 +185,29 @@ let button_include_farm = get_button "include_farm"
let button_include_cheese_shop = get_button "include_cheese_shop"
let button_include_record_shop = get_button "include_record_shop"
let is_checked button = El.prop (El.Prop.bool (Jstr.v "checked")) button
let must_be_included
{ bar
; restaurant
; poetry
; union
; concert
; club
; exhibition
; squat
; hackerspace
; garden
; teahouse
; hammam
; artisanry
; walk
; cheese_shop
; farm
} =
{ bar
; restaurant
; poetry
; union
; concert
; club
; exhibition
; squat
; hackerspace
; garden
; teahouse
; hammam
; artisanry
; walk
; cheese_shop
; record_shop
; farm
} =
let include_bar = is_checked button_include_bar in
let include_restaurant = is_checked button_include_restaurant in
let include_poetry = is_checked button_include_poetry in
@ -218,6 +224,7 @@ let must_be_included
let include_walk = is_checked button_include_walk in
let include_cheese_shop = is_checked button_include_cheese_shop in
let include_farm = is_checked button_include_farm in
let include_record_shop = is_checked button_include_record_shop in
(include_bar && bar)
|| (include_restaurant && restaurant)
|| (include_poetry && poetry) || (include_union && union)
@ -232,6 +239,7 @@ let must_be_included
|| (include_artisanry && artisanry)
|| (include_walk && walk) || (include_farm && farm)
|| (include_cheese_shop && cheese_shop)
|| (include_record_shop && record_shop)
let add_marker { kind; marker } =
if must_be_included kind then
@ -255,8 +263,8 @@ let listen_button button =
let _listener : Ev.listener =
Ev.listen Ev.change
(fun _current_target ->
add_markers ();
add_polylines () )
add_markers ();
add_polylines () )
(El.as_target button)
in
()
@ -277,7 +285,8 @@ let () =
listen_button button_include_artisanry;
listen_button button_include_walk;
listen_button button_include_farm;
listen_button button_include_cheese_shop
listen_button button_include_cheese_shop;
listen_button button_include_record_shop
let popup_with_coord e : unit =
let latlng = Event.latlng e in

Loading…
Cancel
Save