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

Adds i18n support to the theme #49

Merged
merged 11 commits into from
Jun 2, 2019
Prev Previous commit
Next Next commit
Conditional contact form request headers, added ajaxFormspreeGold par…
…am, updated contact form instructions in README
  • Loading branch information
tomanistor committed Apr 16, 2018
commit c470efdd9623aae8ccf85dca17b30feaeb714a88
133 changes: 56 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
![Logo](https://github.com/tomanistor/osprey/blob/master/images/osprey-logo.png)

# Osprey

Osprey is a simple, clean, and fast one-page [Hugo](https://gohugo.io/) portfolio accompanied by a blog.

## Features

- Minimalist, clean, and uncluttered theme
- Portfolio display gallery
- [Disqus](https://disqus.com) comments
- [Formspree](https://formspree.io) AJAX contact form
- Responsive Flexbox Grid
- [SASS](https://sass-lang.com/) styling
- Minimized/compressed CSS and JavaScript files with cachebusting hash setup
- Syntax highlighting with [Highlight.js](https://highlightjs.org/)
- SEO-friendly construction
- [Google Analytics](https://analytics.google.com) and [Google Tag Manager](https://tagmanager.google.com) integration
- [OpenGraph](https://ogp.me/) and [Twitter Cards](https://dev.twitter.com/cards/overview) integration
- Quick loading speeds
- Custom CSS
* Minimalist, clean, and uncluttered theme
* Portfolio display gallery
* [Disqus](https://disqus.com) comments
* [Formspree](https://formspree.io) AJAX contact form (with Formspree Gold)
* [Basin](https://usebasin.com/) AJAX contact form (free)
* Responsive Flexbox Grid
* [SASS](https://sass-lang.com/) styling
* Minimized/compressed CSS and JavaScript files with cachebusting hash setup
* Syntax highlighting with [Highlight.js](https://highlightjs.org/)
* SEO-friendly construction
* [Google Analytics](https://analytics.google.com) and [Google Tag Manager](https://tagmanager.google.com) integration
* [OpenGraph](https://ogp.me/) and [Twitter Cards](https://dev.twitter.com/cards/overview) integration
* Quick loading speeds
* Custom CSS option

## Screenshot

![Screenshot](https://github.com/tomanistor/osprey/blob/master/images/tn.png)

## Installation

### Option 1: Clone Repository

In the root of your Hugo site directory run:

```console
Expand All @@ -36,7 +32,6 @@ $ git clone https://github.com/tomanistor/osprey.git
```

### Option 2: Create Submodule

Create a submodule linked directly to the theme's GitHub repository in order to receive updates:

```console
Expand All @@ -50,7 +45,6 @@ $ git submodule update --init --recursive --remote
```

## Configuration

Osprey comes with several configuration options to aid in site customization. This is an example config.toml file:

```toml
Expand All @@ -66,69 +60,66 @@ disqusShortname = "tomanistor"
disableKinds = ["taxonomy", "taxonomyTerm"] # This theme does not currently use "tag" and "category" taxonomies

[Params]
tagline = "Osprey Example Site"
author = "Toma Nistor"
description = "Full-stack web developer and UI/UX enthusiast based in San Diego, CA."
logoBig = "/images/osprey-logo.png"
logoSmall = "/images/osprey-logo.png"
favicon = "favicon.ico"
opengraphImage = "/images/osprey.png"
twitter = "TomaNistor"
linkedin = "tomanistor"
github = "tomanistor"
facebook = ""
email = ""
googleTagManager = ""
highlightJS = true
copyright = true
credit = true
customCSS = false
cacheBustCSS = false
cacheBustJS = false
# Choose either Formspree contact form or Basin contact form
ajaxFormspree = false
ajaxBasin = "https://usebasin.com/f/0eae7044d4c2"
tagline = "Osprey Example Site"
author = "Toma Nistor"
description = "Full-stack web developer and UI/UX enthusiast based in San Diego, CA."
logoBig = "/images/osprey-logo.png"
logoSmall = "/images/osprey-logo.png"
favicon = "favicon.ico"
opengraphImage = "/images/osprey.png"
twitter = "TomaNistor"
linkedin = "tomanistor"
github = "tomanistor"
facebook = ""
email = ""
googleTagManager = ""
highlightJS = true
copyright = true
credit = true
customCSS = false
cacheBustCSS = false
cacheBustJS = false
# Choose either Formspree contact form or Basin contact form
ajaxFormspree = false
ajaxFormspreeGold = false
ajaxBasin = "https://usebasin.com/f/0eae7044d4c2"

[[menu.main]]
name = "About"
url = "/#about"
weight = 1
name = "About"
url = "/#about"
weight = 1
[[menu.main]]
name = "Work"
url = "/#work"
weight = 2
name = "Work"
url = "/#work"
weight = 2
[[menu.main]]
name = "Blog"
url = "/#blog"
weight = 3
name = "Blog"
url = "/#blog"
weight = 3
[[menu.main]]
name = "Contact"
url = "/#contact"
weight = 4
name = "Contact"
url = "/#contact"
weight = 4
```

## Using Osprey

The two main content types are blog posts and gallery images.

### About Section

To create an about section that renders on the home page, run:

```console
$ hugo new about.md
```

### Blog Posts

To create a new blog post, run:

```console
$ hugo new blog/post-title.md
```

### Gallery Images

To add a new image to your portfolio, run:

```console
Expand All @@ -150,28 +141,19 @@ link2 = "https://github.com/tomanistor"
```

### Contact Form
Two contact forms services are offered as options: Formspree and Basin.

The email address specified in the config.toml file will be one receiving messages sent through the contact form. The contact form is operated by Formspree and requires that the form must be submitted once initially to confirm the email address being used. See instruction [here](https://formspree.io/).

### Contact Form Troubleshooting

If you have problems with the contact form (doing nothing on submit, seems Formspree ajax implementation works only for paid users), just create a copy of `osprey/layouts/partials/body-bottom.html` file inside `your-site/layouts/partials` and remove or comment lines 4 to 8.

Should look like this.
#### Formspree
_Update 4/15/18 - [Formspree no longer offers newly set up AJAX contact forms for free. This is now a Formspree Gold feature.](https://github.com/formspree/formspree/pull/173)_ You can either use the non-AJAX version of Formspree (which redirects to a Captcha page on form submit) by setting the config.toml parameter `ajaxFormspreeGold` to `false`, sign up for Formspree Gold and set the parameter to `true`, or sign up for Basin and use their contact form service for free.

<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
{{ if .IsHome }}
<script src="/scripts/{{ if .Site.Params.cacheBustJS }}{{ index .Site.Data.cachedAssets "index.js" }}{{ else }}index.min.js{{ end }}" type="text/javascript"></script>
{{ else }}
<script src="/scripts/{{ if .Site.Params.cacheBustJS }}{{ index .Site.Data.cachedAssets "main.js" }}{{ else }}main.min.js{{ end }}" type="text/javascript"></script>
{{ end }}
The email address specified in the config.toml file will be the one receiving messages sent through the contact form. The contact form is operated by Formspree and requires that the form must be submitted once initially to confirm the email address being used. See instruction [here](https://formspree.io/).

That will override the original osprey body-bottom.html and remove the ajax script. Now you can receive messages through your contact form without any problem.
#### Basin
Basin is an alternative, free AJAX contact form service. To use Basin, [sign up for a free account](https://usebasin.com/users/sign_up) and create a form. Copy and paste your form's URL endpoint to the `ajaxBasin` config.toml parameter. To use this as an AJAX form, remove the `Redirect URL` and select `Submit this form via AJAX` on your Basin dashboard.

PD: This will add an extra step to the contact form, on submitting the user need to fill a captcha before sending the message.
![Basin AJAX setup](https://github.com/tomanistor/osprey/blob/master/images/basin-ajax-setup.png)

### Custom CSS

To implement custom CSS sitewide, change the config.toml parameter `customCSS` from `false` to `true` and then create a `css.html` file in your `layouts/partials/` folder like the example below:

```html
Expand All @@ -186,13 +168,10 @@ To implement custom CSS sitewide, change the config.toml parameter `customCSS` f
This will render inline CSS in the head of your site and without adding an extra HTTP request.

### Cache Busting

To implement cache busting of CSS and JS static assets with something like Gulp.js and [gulp-hash](https://www.npmjs.com/package/gulp-hash), change the config.toml parameters `cacheBustCSS` and `cacheBustJS` from `false` to `true` and follow [this setup guide](https://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/#building-a-gulp-pipeline:c9938300a3bdba2018b469c2485ca2b6).

## Contributions

If you'd like to help with the development of this theme, I encourage you to submit a pull request or create an issue if you find a bug. All help is appreciated.

## License

This theme is released under the GNU 3.0 license. For more information read the [license](https://github.com/tomanistor/osprey/blob/master/LICENSE).
69 changes: 35 additions & 34 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,43 @@ disqusShortname = "tomanistor"
disableKinds = ["taxonomy", "taxonomyTerm"] # This theme does not currently use "tag" and "category" taxonomies

[Params]
tagline = "Osprey Example Site"
author = "Toma Nistor"
description = "Full-stack web developer and UI/UX enthusiast based in San Diego, CA."
logoBig = "/images/osprey-logo.png"
logoSmall = "/images/osprey-logo.png"
favicon = "favicon.ico"
opengraphImage = "/images/osprey.png"
twitter = "TomaNistor"
linkedin = "tomanistor"
github = "tomanistor"
facebook = ""
email = ""
googleTagManger = ""
highlightJS = true
copyright = true
credit = true
customCSS = false
cacheBustCSS = false
cacheBustJS = false
# Choose either Formspree contact form or Basin contact form
ajaxFormspree = false
ajaxBasin = "https://usebasin.com/f/0eae7044d4c2"
tagline = "Osprey Example Site"
author = "Toma Nistor"
description = "Full-stack web developer and UI/UX enthusiast based in San Diego, CA."
logoBig = "/images/osprey-logo.png"
logoSmall = "/images/osprey-logo.png"
favicon = "favicon.ico"
opengraphImage = "/images/osprey.png"
twitter = "TomaNistor"
linkedin = "tomanistor"
github = "tomanistor"
facebook = ""
email = ""
googleTagManger = ""
highlightJS = true
copyright = true
credit = true
customCSS = false
cacheBustCSS = false
cacheBustJS = false
# Choose either Formspree contact form or Basin contact form
ajaxFormspree = false
ajaxFormspreeGold = false
ajaxBasin = "https://usebasin.com/f/0eae7044d4c2"

[[menu.main]]
name = "About"
url = "/#about"
weight = 1
name = "About"
url = "/#about"
weight = 1
[[menu.main]]
name = "Work"
url = "/#work"
weight = 2
name = "Work"
url = "/#work"
weight = 2
[[menu.main]]
name = "Blog"
url = "/#blog"
weight = 3
name = "Blog"
url = "/#blog"
weight = 3
[[menu.main]]
name = "Contact"
url = "/#contact"
weight = 4
name = "Contact"
url = "/#contact"
weight = 4
Binary file added images/basin-ajax-setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion layouts/partials/body-bottom.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
{{ if .IsHome }}
<script src="/scripts/{{ if .Site.Params.cacheBustJS }}{{ index .Site.Data.cachedAssets "index.js" }}{{ else }}index.min.js{{ end }}" type="text/javascript"></script>
{{ if or (.Site.Params.ajaxFormspree) (.Site.Params.ajaxBasin) }}
{{ if or (and (.Site.Params.ajaxFormspree) (.Site.Params.ajaxFormspreeGold)) (.Site.Params.ajaxBasin) }}
<script>{{ partial "scripts/contact.min.js" . | safeJS }}</script>
{{ end }}
{{ else }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/scripts/contact.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/scripts/contact.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/scripts/src/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ $('#form-contact').addEventListener('submit', function(e) {
email:email,
_subject:subject,
message:message,
}
};

// Send to Formspree or Basin
request.open('POST', '{{ if .Site.Params.ajaxFormspree }}https://formspree.io/{{ .Site.Params.email }}{{ else if .Site.Params.ajaxBasin }}{{ .Site.Params.ajaxBasin }}.json{{ end }}', true);
request.setRequestHeader('Accept', 'application/json; charset=UTF-8');
request.setRequestHeader('{{ if .Site.Params.ajaxFormspree }}Content-Type{{ else if .Site.Params.ajaxBasin }}Accept{{ end }}', 'application/json; charset=UTF-8');
// Call function when the state changes
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
Expand Down