Skip to content

Add dynamic "next meetup" to home page#33

Open
iLtc wants to merge 9 commits intotechcorridorio:masterfrom
iLtc:next-meetup
Open

Add dynamic "next meetup" to home page#33
iLtc wants to merge 9 commits intotechcorridorio:masterfrom
iLtc:next-meetup

Conversation

@iLtc
Copy link
Copy Markdown
Contributor

@iLtc iLtc commented Feb 11, 2017

This pull request tries to resolve #27 .

image

Note: The javascript code, include the api signature, modify from _includes/meetup_cards.html .

We can also:

  • Add event description to the alt attribute
  • Change date format
  • Change link style
  • Move the javascript code to a separate file

Comment thread index.html

// Modify from _includes/meetup_cards.html

window.onload = function(){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably use $(document).ready(function ...) (or just $(function ...))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I cannot use $(document).ready(function ...) here since jQuery will be imported after this code. Would you mind if I move <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> to <head>?

Comment thread index.html
</div>

{% raw %}
<script type="text/javascript">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be nice to have this in a separate .js file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved most of the js code to js/meetup-events.js but left the trigger code here.

Comment thread index.html Outdated
</div>
</div>

{% raw %}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed it.

Comment thread index.html Outdated
//assume Mustache is loaded
//assume Meetup is loaded

// Modify from _includes/meetup_cards.html
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we refactor that code so it's reusable without copying and pasting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved all the js code to js/meetup-events.js. If you want, I can refactor _includes/meetup_cards.html and _includes/developers_cards.html so they share the same code file.

@benjaminoakes
Copy link
Copy Markdown
Member

This is exactly what I was hoping for, but we should probably clean up the code a little before merging.

Comment thread js/meetup-events.js Outdated
};

var createEventParagraph = function (event) {
var template = "Next meetup: <a href='{{event_url}}' target='_blank'>{{name}} ({{formattedShortDate}})</a>";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long.
Mixed double and single quotes.

Comment thread js/meetup-events.js Outdated
+ (date.getHours() % 12) + ':'
+ (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes())
+ ' '
+ (date.getHours() < 12 ? 'AM' : 'PM');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Misleading line break before '+'; readers may interpret this as an expression boundary.

Comment thread js/meetup-events.js Outdated
+ ' at '
+ (date.getHours() % 12) + ':'
+ (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes())
+ ' '
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Misleading line break before '+'; readers may interpret this as an expression boundary.

Comment thread js/meetup-events.js Outdated
+ date.getFullYear()
+ ' at '
+ (date.getHours() % 12) + ':'
+ (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long.
Misleading line break before '+'; readers may interpret this as an expression boundary.

Comment thread js/meetup-events.js Outdated
+ date.getDate() + ', '
+ date.getFullYear()
+ ' at '
+ (date.getHours() % 12) + ':'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Misleading line break before '+'; readers may interpret this as an expression boundary.

Comment thread js/meetup-events.js Outdated
var months = [
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mixed double and single quotes.

Comment thread js/meetup-events.js Outdated
var day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = [
"January", "February", "March", "April",
"May", "June", "July", "August",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mixed double and single quotes.

Comment thread js/meetup-events.js Outdated

var day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = [
"January", "February", "March", "April",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mixed double and single quotes.

Comment thread js/meetup-events.js Outdated
return "http://maps.google.com/?q=" + encodeURI(venue.address_1) + '+' + encodeURI(venue.city);
};

var day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long.
Mixed double and single quotes.

Comment thread js/meetup-events.js Outdated

var EventPresenter = function(event) {
var formatVenueLink = function(venue) {
return "http://maps.google.com/?q=" + encodeURI(venue.address_1) + '+' + encodeURI(venue.city);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long.
Mixed double and single quotes.
Identifier 'address_1' is not in camel case.

Comment thread js/meetup-events.js
return event;
};

var createEventParagraph = function (event) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'createEventParagraph' is defined but never used.

Comment thread js/meetup-events.js
};
};

var EventPresenter = function(event) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'EventPresenter' is defined but never used.

Comment thread js/meetup-events.js
var template = 'Next meetup: <a href=\'{{event_url}}\' target=\'_blank\'>' +
'{{name}} ({{formattedShortDate}})</a>';
Mustache.parse(template); // optional, speeds up future uses
var rendered = Mustache.render(template, event);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'Mustache' is not defined.

Comment thread js/meetup-events.js
var createEventParagraph = function (event) {
var template = 'Next meetup: <a href=\'{{event_url}}\' target=\'_blank\'>' +
'{{name}} ({{formattedShortDate}})</a>';
Mustache.parse(template); // optional, speeds up future uses
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'Mustache' is not defined.

Comment thread js/meetup-events.js
'+' + encodeURI(venue.city);
};

var day = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long.

@iLtc
Copy link
Copy Markdown
Contributor Author

iLtc commented Mar 13, 2018

Sorry for the delay. I hope it was not too late.

It is a little bit difficult to solve all the problems raised by HoundCI. For example, Mustache is defined in another file. I am not sure how to fix it here.

Let me know what you think~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dynamic "next meetup" to home page

3 participants