Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow full url in theme arg in install_theme (#270) #271

Merged
merged 7 commits into from
Mar 6, 2018
3 changes: 2 additions & 1 deletion R/hugo.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ install_theme = function(
return(invisible())
}
branch = sub('^@', '', gsub(r, '\\2', theme))
if (branch == '') branch = 'master'
if (branch == '' | theme_is_url) branch = 'master'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| -> ||

theme = gsub(r, '\\1', theme)
dir_create('themes')
in_dir('themes', {
Expand Down Expand Up @@ -179,6 +179,7 @@ install_theme = function(
'because not all Hugo themes work with any config files.'
)
newdir = gsub(tmpdir, ".", zipdir)
newdir = gsub("-[a-f0-9]{12,40}$", "", newdir)
newdir = gsub(sprintf('-%s$', branch), '', newdir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihui Should I add an if (!theme_is_url) here so that it doesn't even try to change the filename if the zip file is given? The alternative would be to add some logic around the branch regex and then hope we get lucky at this stage ... so seems to me to be better to skip this if theme_is_url. I didn't do this because I was trying not to add a ton of logic and branching paths, but it's been nagging at me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditioning on theme_is_url makes sense to me.

if (!force && dir_exists(newdir)) stop(
'The theme already exists. Try install_theme("', theme, '", force = TRUE) ',
Expand Down