mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Improve bootstrap-datepicker update tools, add docs
This commit is contained in:
@@ -529,7 +529,17 @@
|
||||
},
|
||||
|
||||
_utc_to_local: function(utc){
|
||||
return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
|
||||
|
||||
if (!utc) return utc;
|
||||
|
||||
var local = new Date(utc.getTime() + (utc.getTimezoneOffset() * 60000));
|
||||
|
||||
if (local.getTimezoneOffset() != utc.getTimezoneOffset())
|
||||
{
|
||||
local = new Date(utc.getTime() + (local.getTimezoneOffset() * 60000));
|
||||
}
|
||||
|
||||
return utc && local;
|
||||
},
|
||||
_local_to_utc: function(local){
|
||||
return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
|
||||
|
||||
@@ -92,3 +92,27 @@ To update the version of babel-polyfill:
|
||||
* Run `yarn add --dev babel-polyfill --exact`.
|
||||
* Edit R/shinyui.R. The `renderPage` function has an `htmlDependency` for
|
||||
`babel-polyfill`. Update this to the new version number.
|
||||
|
||||
# Updating and patching `bootstrap-datepicker`
|
||||
|
||||
## Updating
|
||||
|
||||
[bootstrap-datepicker](https://github.com/uxsolutions/bootstrap-datepicker) can be updated with the script `updateBootstrapDatepicker.R`.
|
||||
|
||||
After updating, our patches to `bootstrap-datepicker` must be applied using the script `applyDatepickerPatches.R`
|
||||
|
||||
After updating and applying patches, `yarn grunt` should be run per the instructions above.
|
||||
|
||||
## Making a new patch
|
||||
|
||||
To create a new patch:
|
||||
|
||||
1. Make any necessary changes to files in `inst/www/shared/datepicker`
|
||||
1. **Do not commit your changes.**
|
||||
1. Instead, create a patch with a command like `git diff > tools/datepicker-patches/012-a-description.patch`
|
||||
1. Add the new `.patch` file to the repo with a descriptive commit message
|
||||
1. Revert `bootstrap-datepicker` to its unpatched state by running `updateBootstrapDatepicker.R`
|
||||
1. Apply all patches, including the one you just made, by running `applyDatepickerPatches.R`
|
||||
1. Run `yarn grunt`
|
||||
1. Test your changes
|
||||
1. `git add` the new `.patch` and any resulting changes
|
||||
|
||||
18
tools/applyDatepickerPatches.R
Executable file
18
tools/applyDatepickerPatches.R
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env Rscript
|
||||
# Applies patches stored in tools/datepicker-patches
|
||||
# Should be run after running tools/updateBootstrapDatepicker.R
|
||||
|
||||
library(rprojroot)
|
||||
|
||||
patch_dir <- rprojroot::find_package_root_file("tools/datepicker-patches")
|
||||
|
||||
for (patch in list.files(patch_dir, full.names = TRUE)) {
|
||||
tryCatch({
|
||||
message(sprintf("Applying %s", basename(patch)))
|
||||
system(sprintf("git apply '%s'", patch))
|
||||
},
|
||||
error = function(e) {
|
||||
quit(save = "no", status = 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1,33 +1,24 @@
|
||||
#!/usr/bin/env Rscript
|
||||
# Retrieves a particular version of bootstrap-datepicker:
|
||||
# https://github.com/uxsolutions/bootstrap-datepicker
|
||||
# After retrieving, applies the series of patches contained
|
||||
# in tools/datepicker-patches to inst/www/shared/datepicker/
|
||||
# After retrieving, you can apply patches stored in
|
||||
# tools/datepicker-patches with applyDatepickerPatches.R
|
||||
|
||||
library(rprojroot)
|
||||
|
||||
version <- "1.6.4"
|
||||
patch_dir <- rprojroot::find_package_root_file("tools/datepicker-patches")
|
||||
dest_dir <- rprojroot::find_package_root_file("inst/www/shared/datepicker")
|
||||
tag <- paste0("v", version)
|
||||
dest_file <- file.path(tempdir(), paste0("bootstrap-datepicker-", version, ".zip"))
|
||||
url <- sprintf("https://github.com/uxsolutions/bootstrap-datepicker/releases/download/%s/bootstrap-datepicker-%s-dist.zip", tag, version)
|
||||
|
||||
fetch_datepicker <- function() {
|
||||
tag <- paste0("v", version)
|
||||
dest_file <- file.path(tempdir(), paste0("bootstrap-datepicker-", version, ".zip"))
|
||||
url <- sprintf("https://github.com/uxsolutions/bootstrap-datepicker/releases/download/%s/bootstrap-datepicker-%s-dist.zip", tag, version)
|
||||
download.file(url, dest_file)
|
||||
unzip(
|
||||
dest_file,
|
||||
files = c(
|
||||
"js/bootstrap-datepicker.js",
|
||||
"css/bootstrap-datepicker3.css",
|
||||
"css/bootstrap-datepicker3.min.css"
|
||||
),
|
||||
exdir = dest_dir
|
||||
)
|
||||
}
|
||||
|
||||
apply_patches <- function() {
|
||||
}
|
||||
|
||||
fetch_datepicker()
|
||||
apply_patches()
|
||||
download.file(url, dest_file)
|
||||
unzip(
|
||||
dest_file,
|
||||
files = c(
|
||||
"js/bootstrap-datepicker.js",
|
||||
"css/bootstrap-datepicker3.css",
|
||||
"css/bootstrap-datepicker3.min.css"
|
||||
),
|
||||
exdir = dest_dir
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user