Add NYTimes recipe extraction from __NEXT_DATA__ JSON tag

- Add Roux.NYTimes module with:
  - extractNextData: finds <script id="__NEXT_DATA__"> tag in HTML
    and parses its JSON content via aeson
  - parseNYTRecipe: maps NYTimes recipe JSON structure into a
    typed intermediate representation (NYTRecipe, NYTIngredientGroup,
    NYTIngredientItem, NYTStepGroup, NYTStepItem)
- Supports all NYTimes Cooking data: title, URL, total time, yield,
  topnote, ingredient groups (with section names), step groups
- Add aeson to dependencies
- Add 4 tests: extraction + parsing for both fried-rice and
  carrot-risotto example HTML files
- Wire NYTimesSpec into test runner
This commit is contained in:
2026-05-19 15:51:37 -04:00
parent 262faca90e
commit 21a4cea083
7 changed files with 443 additions and 4 deletions
+10 -4
View File
@@ -18,6 +18,7 @@ library
exposed-modules:
Roux
Roux.Html
Roux.NYTimes
Roux.Parser
Roux.RecipeIndex
Roux.Server
@@ -35,7 +36,8 @@ library
TupleSections
ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, blaze-html
, blaze-markup
, bytestring
@@ -66,7 +68,8 @@ executable check-recipes
TupleSections
ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, blaze-html
, blaze-markup
, bytestring
@@ -98,7 +101,8 @@ executable roux-server
TupleSections
ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, blaze-html
, blaze-markup
, bytestring
@@ -120,6 +124,7 @@ test-suite roux-server-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Roux.NYTimesSpec
Roux.ParserSpec
Paths_roux_server
autogen-modules:
@@ -133,7 +138,8 @@ test-suite roux-server-test
TupleSections
ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, blaze-html
, blaze-markup
, bytestring