(define-module (datat-website-package)
  #:use-module (guix)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix build-system ruby)
  #:use-module (gnu packages ruby))

(define vcs-file?
  (or (git-predicate (string-append (current-source-directory) "/../.."))
      (const #t)))

(define-public datat.fi-website
  (package
    (name "datat.fi-website")
    (version "0.0.0")
    (source (local-file "../.." "datat.fi-website-checkout"
                        #:recursive? #t
                        #:select? vcs-file?))
    (build-system ruby-build-system)
    (arguments
      (list
        #:tests? #f
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'build 'build-html
              (lambda _
                (setenv "JEKYLL_ENV" "production")
                (invoke "jekyll" "build")))
            (replace 'install
              (lambda _
                (map delete-file (find-files "_site" "\\.gem(spec)?$|\\.scm$"))
                (copy-recursively "_site" (string-append #$output "/srv/datat.fi-website/"))))))) ; no tests
    (native-inputs
      (list
        jekyll
        ruby-jekyll-feed
        ruby-jekyll-paginate
        ruby-jekyll-seo-tag
        ruby-jekyll-sitemap))
    (synopsis "Datat.fi website")
    (description "HTML site on https://datat.fi")
    (home-page "https://git.datat.fi/ry/datat.fi")
    (license license:expat)))

(define ruby-jekyll-paginate
  (package
    (name "ruby-jekyll-paginate")
    (version "1.1.0")
    (source (origin
              (method url-fetch)
              (uri (rubygems-uri "jekyll-paginate" version))
              (sha256
               (base32
                "0r7bcs8fq98zldih4787zk5i9w24nz5wa26m84ssja95n3sas2l8"))))
    (build-system ruby-build-system)
    (arguments
      (list
        #:tests? #f)) ; no tests
    (synopsis "Built-in Pagination Generator for Jekyll")
    (description "Built-in Pagination Generator for Jekyll")
    (home-page "https://github.com/jekyll/jekyll-paginate")
    (license license:expat)))

datat.fi-website
