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 Possibility to render an average star rating info block #20

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
# trim_trailing_whitespace = false
# insert_final_newline = false
93 changes: 55 additions & 38 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,97 @@ this will get the 5 reviews, google offers you. if you need more, let me direct
The NPM Package is [here](https://github.com/simonneutert/google-maps-reviews) - Frontend Devs will know how to webpack :) or simply extract the code and adapt it to your needs, dropping jQuery as a dependency.

## Credits

Inspired by Steven Monson's magnificent article here:
https://www.launch2success.com/guide/display-google-reviews-website-2017/ or check out [Steven's github](https://github.com/stevenmonson/googleReviews). Steven's code is based on [peledies jquery plugin repo](https://github.com/peledies/google-places). So, I simply remixed their work into this repo. *Thank you guys!*
https://www.launch2success.com/guide/display-google-reviews-website-2017/ or check out [Steven's github](https://github.com/stevenmonson/googleReviews). Steven's code is based on [peledies jquery plugin repo](https://github.com/peledies/google-places). So, I simply remixed their work into this repo. _Thank you guys!_

#### Dear beginners and copy-pasters

:octocat: *For those of you, who are new in programming or can only copy-paste, please make sure, that jQuery, the Google Maps API and the .js-file of this plugin are successfully loaded, before you call this script in your html page.*
:octocat: _For those of you, who are new in programming or can only copy-paste, please make sure, that jQuery, the Google Maps API and the .js-file of this plugin are successfully loaded, before you call this script in your html page._

*./demo/index.html is a working demo, the comments will guide you :wink:*
_./demo/index.html is a working demo, the comments will guide you :wink:_

## Prerequisites

* You must have jQuery in your project: [jQuery](http://jquery.com)
- You must have jQuery in your project: [jQuery](http://jquery.com)

* add the .js and .css of this repo to your project (see ./demo/index.html for inspiration :wink:)
- add the .js and .css of this repo to your project (see ./demo/index.html for inspiration :wink:)

* ___if you do not have a working Google Maps API key already:___ create a Google API Key: [https://console.developers.google.com/apis/](https://console.developers.google.com/apis/) **make sure to set a limit to your payments**
- **_if you do not have a working Google Maps API key already:_** create a Google API Key: [https://console.developers.google.com/apis/](https://console.developers.google.com/apis/) **make sure to set a limit to your payments**

* add the following line with your Google Maps API key with the key param:
- add the following line with your Google Maps API key with the key param:

``` html
```html
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=YourApiKeyHere"></script>
```

* add an empty ***div*** element in your html template with an unique ID, where the reviews should show up. In this case:
- add an empty **_div_** element in your html template with an unique ID, where the reviews should show up. In this case:

`<div id="google-reviews"></div>`

## How to get link to “View All Google Reviews” or "Write a review"

Please see the official Documents for this topic:
https://developers.google.com/my-business/content/review-data#list_all_reviews

* Step 1. Open a browser, but don’t use Chrome. You can use Firefox, or Edge, or even Internet Explorer but not Google Chrome because it alters the URL and your link will not work correctly.
- Step 1. Open a browser, but don’t use Chrome. You can use Firefox, or Edge, or even Internet Explorer but not Google Chrome because it alters the URL and your link will not work correctly.

* Step 2. Go to [Google.com](http://www.google.com) and search for your company’s name.
- Step 2. Go to [Google.com](http://www.google.com) and search for your company’s name.

* Step 3. Find the card on the right and click “View All Google Reviews” or "Write a review"
- Step 3. Find the card on the right and click “View All Google Reviews” or "Write a review"

* Step 4. Copy the URL in the address bar.
- Step 4. Copy the URL in the address bar.

* Step 5. Now paste the URL as a link on `more_reviews_button_url` or `write_review_button_url` param.
- Step 5. Now paste the URL as a link on `more_reviews_button_url` or `write_review_button_url` param.

## Call the Plugin

[Grab your place's ID (https://developers.google.com/places/place-id) and call it as ***placeId*** parameter, when calling the plugin. ](https://developers.google.com/places/place-id)
[Grab your place's ID (https://developers.google.com/places/place-id) and call it as **_placeId_** parameter, when calling the plugin. ](https://developers.google.com/places/place-id)

``` html
```html
<script>
jQuery(document).ready(function($) {
if ($("#google-reviews").length == 0) {
return
}
// Find a placeID via https://developers.google.com/places/place-id
$("#google-reviews").googlePlaces({
placeId: 'ChIJZa6ezJa8j4AR1p1nTSaRtuQ',
// the following params are optional (default values)
header: "<h3>Google Reviews</h3>", // html/text over Reviews
footer: '', // html/text under Reviews block
maxRows: 5, // max 5 rows of reviews to be displayed
minRating: 4, // minimum rating of reviews to be displayed
months: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
textBreakLength: "90", // length before a review box is set to max width
shortenNames: true, // example: "Max Mustermann" -> "Max M."",
moreReviewsButtonUrl: '', // url to Google Place reviews popup
moreReviewsButtonLabel: 'Show More Reviews',
writeReviewButtonUrl: '', // url to Google Place write review popup
writeReviewButtonLabel: 'Write New Review',
showProfilePicture: true
jQuery(document).ready(function ($) {
if ($("#google-reviews").length == 0) {
return;
}
// Find a placeID via https://developers.google.com/places/place-id
$("#google-reviews").googlePlaceReviews({
placeId: "ChIJZa6ezJa8j4AR1p1nTSaRtuQ",
// the following params are optional (default values)
header: "<h3>Google Reviews</h3>", // html/text over Reviews
footer: "", // html/text under Reviews block
maxRows: 5, // max 5 rows of reviews to be displayed
minRating: 4, // minimum rating of reviews to be displayed
months: [
"Jan",
"Feb",
"Mär",
"Apr",
"Mai",
"Jun",
"Jul",
"Aug",
"Sep",
"Okt",
"Nov",
"Dez",
],
renderAverage: false, // render average reviews and stars
renderReviews: true, // render reviews
textBreakLength: "90", // length before a review box is set to max width
shortenNames: true, // example: "Max Mustermann" -> "Max M."",
moreReviewsButtonUrl: "", // url to Google Place reviews popup
moreReviewsButtonLabel: "Show More Reviews",
writeReviewButtonUrl: "", // url to Google Place write review popup
writeReviewButtonLabel: "Write New Review",
showProfilePicture: true,
});
});
});
</script>
```

## Are Pull Requests welcome?

Yes, of course :octocat:

**You do not need to update the demo folder!** I will do this, when your code was merged.
1 change: 0 additions & 1 deletion demo/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions demo/index.html

This file was deleted.

13 changes: 0 additions & 13 deletions demo/node_modules/jquery-google-reviews/LICENSE

This file was deleted.

79 changes: 0 additions & 79 deletions demo/node_modules/jquery-google-reviews/Readme.md

This file was deleted.

Loading