Code Monkey home page Code Monkey logo

Comments (9)

cderv avatar cderv commented on September 18, 2024 1
  1. I was curious why we have this | -> in fact, this appending of chapter name to title books is a bookdown feature in prepend_chapter_title() called in split_chapters(). Usually, the prepending does not happen on first page of the bookdown because book title is the same as first header. But this is not the case with bs4_book() and any other template that would not add a title part in there template. I can deal with it in bookdown.org but it feels that this preprend feature can maybe evolved to not preprend anything on index.html ?

  2. Metadata are missing for now in bs4_book(): rstudio/bookdown#1034

  3. The file for bs4_book() is called search.json. It returns:

httr::headers(httr::HEAD(paste0("https://adv-r.hadley.nz/", 'search.json')))$`content-length`
#> [1] "759493"
  1. No bs4_book() does not have the date in header. If date field is passed in YAML header, it is used to fill a text in the footer: See https://devguide.ropensci.org/

I think we could adapt the script here, but also suggest some addition in bs4_book().

from bookdown.org.

cderv avatar cderv commented on September 18, 2024 1

Just sharing here for reference why bookdown will prepend the header of the file in title.
I think this because sometimes, users forgot to set the title: field in index.Rmd and the filename will be used as title. This leads to title like this (source)

<title>Dissertating with RMarkdown and Bookdown | dissertating_rmd_presentation.utf8.md</title>

So, sometimes the second part of the title is not what we want...

from bookdown.org.

yihui avatar yihui commented on September 18, 2024
  1. Okay, I see. It was because of https://github.com/rstudio/bookdown/blob/6ae8ead/R/html.R#L1112. Let's just do title = gsub('.*\\|\\s*', '', title) for now.
  2. I see.
  3. I see. It will be nice if bs4_book could use the same filename as gitbook (i.e., search_index.json), so we don't need to try two locations here.
  4. It doesn't matter where the date is inserted on the page, as long as it can be found.

Thanks!

from bookdown.org.

cderv avatar cderv commented on September 18, 2024

After running the new script for test, it seems there is also an issue with the summary description.

diff --git a/content/archive/external/adv-r-hadley-nz.md b/content/archive/external/adv-r-hadley-nz.md
index f731283..adbcadc 100644
--- a/content/archive/external/adv-r-hadley-nz.md
+++ b/content/archive/external/adv-r-hadley-nz.md
@@ -4,10 +4,8 @@ author: "Hadley Wickham"
 date: ""
 tags: [Advanced R, R Programming]
 link: "https://adv-r.hadley.nz/"
-length_weight: "35%"
-cover: "https://adv-r.hadley.nz/cover.png"
-repo: "hadley/adv-r"
+length_weight: "32.8%"
 pinned: true
 ---

-The book is designed primarily for R users who want to improve their programming skills and understanding of the language. It should also be useful for programmers coming to R from other languages, as help you to understand why R works the way it does. [...] This is the website for the 2nd edition of “Advanced R”, a book in Chapman & Hall’s R Series. The book is designed primarily for R users who want to improve their programming skills and understanding of the language. It should also be useful for programmers coming to R from other languages, as it helps you to understand why R works the ...
+View book source This is the website for 2nd edition of “Advanced R”, a book in Chapman & Hall’s R Series. The book is designed primarily for R users who want to improve their programming skills and understanding of the language. It should also be useful for programmers coming to R from other languages, as help you to understand why R works the way it does. If you’re looking for the 1st edition, you can find it at http://adv-r.had.co.nz/. This work, as a whole, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. The code contained in this
book ...

View book source is a button text that we should not retrieve.

from bookdown.org.

cderv avatar cderv commented on September 18, 2024

It seems also that some JSON file does not offer content-length in the header.

str(httr::headers(httr::HEAD("https://advanced-r-solutions.rbind.io/search.json")))
#> List of 16
#>  $ date            : chr "Mon, 08 Mar 2021 16:48:21 GMT"
#>  $ content-type    : chr "application/json"
#>  $ connection      : chr "keep-alive"
#>  $ set-cookie      : chr "__cfduid=dbb4b62d94d5ea2fdac23cb9cba7f2fa61615222100; expires=Wed, 07-Apr-21 16:48:20 GMT; path=/; domain=.rbin"| __truncated__
#>  $ cache-control   : chr "public, max-age=0, must-revalidate"
#>  $ etag            : chr "W/\"cb7a3c92d216f158f69b287f9782556b-ssl\""
#>  $ age             : chr "2360"
#>  $ x-nf-request-id : chr "7c4cca55-d8a8-42bf-a4ea-2a326e13fe5b-65283787"
#>  $ cf-cache-status : chr "DYNAMIC"
#>  $ cf-request-id   : chr "08b4566b890000088332b1d000000001"
#>  $ expect-ct       : chr "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
#>  $ report-to       : chr "{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report?s="| __truncated__
#>  $ nel             : chr "{\"report_to\":\"cf-nel\",\"max_age\":604800}"
#>  $ server          : chr "cloudflare"
#>  $ cf-ray          : chr "62cd8cf27ca50883-CDG"
#>  $ content-encoding: chr "gzip"
#>  - attr(*, "class")= chr [1:2] "insensitive" "list"

Created on 2021-03-08 by the reprex package (v1.0.0.9002)

This will lead to O length. Do we want to prevent this ?

It would require reading the file probably and maybe we don't want that.

from bookdown.org.

cderv avatar cderv commented on September 18, 2024

Also a another note on book length: It seems the length of bs4_book() json is different for gitbook() - as we normalize the length, I think it will reduce the length of all books.

That maybe because json is different. Don't know how we want this to be a useful and correct measure.

from bookdown.org.

cderv avatar cderv commented on September 18, 2024

I have dealt for bs4_book() with

  • Book cover not in meta but in main page
  • Repo url which is in another place we can find
  • description creation if none is provided

This should cover most of the case we have. I'll share this in a PR soon

from bookdown.org.

cderv avatar cderv commented on September 18, 2024

This is mainly taken into account by #64

from bookdown.org.

yihui avatar yihui commented on September 18, 2024

It seems also that some JSON file does not offer content-length in the header.

Just ignore them.

Also a another note on book length: It seems the length of bs4_book() json is different for gitbook() - as we normalize the length, I think it will reduce the length of all books.

That maybe because json is different. Don't know how we want this to be a useful and correct measure.

The measure doesn't need to be accurate. A rough estimator is fine.

from bookdown.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.