Skip to content

Commit

Permalink
support x-forwarded-for for multiverse
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jul 7, 2024
1 parent a918b11 commit 8864fb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ app.use(function(req, res, next){
req.universe = process.env.UNIVERSE;
} else if(req.app.get('env') === 'production'){
req.universe = req.hostname.replace('.r-universe.dev', '');
res.locals.vhost = req.headers['r-universe-vhost'];
}
res.locals.universe = req.universe || 'ropensci';
res.locals.node_env = req.app.get('env');
Expand Down
3 changes: 2 additions & 1 deletion static/pkginfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ function update_copy_gist(){
var link = $('#copy-code-button').unbind("click");
var tooltip_text = 'Copy to clipboard';
link.click(function(e){
var vhost = $(".universe-vhost-url").text();
var txt = (universe == 'cran') ?
`install.packages("${package}", repos = "https://cloud.r-project.org")` :
`install.packages("${package}", repos = c("https://${universe}.r-universe.dev", "https://cloud.r-project.org"))`;
`install.packages("${package}", repos = c("${vhost}", "https://cloud.r-project.org"))`;
navigator.clipboard.writeText(txt).then(function(e){
link.attr('data-bs-original-title', 'Copied!').tooltip('dispose').tooltip('show');
link.attr('data-bs-original-title', tooltip_text);
Expand Down
8 changes: 3 additions & 5 deletions views/pkginfo.pug
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ block content
span.package-details-gist-name #{Package}
span.pl-pds '
| ,
span.pl-v repos
span.pl-v repos
span.pl-k =
span.nocran
| c(
span.pl-s
span.pl-pds '
| https://
span.title-universe-name #{universe}
| .r-universe.dev
span.universe-vhost-url https://#{vhost || `${universe}.r-universe.dev`}
span.pl-pds '
| ,
span.pl-s
Expand Down Expand Up @@ -360,4 +358,4 @@ block after_scripts
script(src='https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-annotation/3.0.1/chartjs-plugin-annotation.min.js')
script(src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js')
script(src='https://cdnjs.cloudflare.com/ajax/libs/chartjs-adapter-moment/1.0.1/chartjs-adapter-moment.min.js')
script(src='pkginfo.js?nocache=2')
script(src='pkginfo.js?nocache=3')

0 comments on commit 8864fb6

Please sign in to comment.