diff --git a/README.md b/README.md index 02f7de835..be9609dd8 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,13 @@ If a process could be improved, don't hesitate to bring it up, but there are alw 1. `git clone git@github.com:thepracticaldev/dev.to_core.git` 2. `bundle install` 3. `bin/yarn` -4. `bin/setup` -5. Set up your environment variables/secrets +4. Set up your environment variables/secrets - Create a `config/application.yml` file to store development secrets. This is a personal file that is ignored in git. - Copy [`config/sample_application.yml`](config/sample_application.yml) in order to create a valid `application.yml` - - You'll need to get your own free API keys for a few services. [**Follow this wiki to get them.**](https://github.com/thepracticaldev/dev.to_core/wiki/Getting-API-Keys-for-Basic-Development) + - You'll need to get your own free API keys for a few services in order to get your development environment running. [**Follow this wiki to get them.**](https://github.com/thepracticaldev/dev.to_core/wiki/Getting-API-Keys-for-Basic-Development) - If you are missing `ENV` variables on bootup, `_env_checker.rb` will let you know. If you add or remove `ENV` vars to the project, you must also modify this file before they can be merged. The wiki above should handle all the necessary keys for basic development. +5. Run `bin/setup` + #### Starting the application We're mostly a Rails app, with a bit of Webpack sprinkled in. **For most cases, simply running `bin/rails server` will do.** If you're working with Webpack though, you'll need to run the following: diff --git a/app/assets/javascripts/initializePage.js.erb b/app/assets/javascripts/initializePage.js.erb index 8a9d74a1c..535503fbd 100644 --- a/app/assets/javascripts/initializePage.js.erb +++ b/app/assets/javascripts/initializePage.js.erb @@ -40,6 +40,7 @@ function callInitalizers(){ initializeFooterMod(); initializeCommentPreview(); initializeAdditionalContentBoxes(); + initializeTimeFixer(); if (!initializeLiveArticle.called){ initializeLiveArticle(); } diff --git a/app/assets/javascripts/initializers/initializeTimeFixer.js b/app/assets/javascripts/initializers/initializeTimeFixer.js new file mode 100644 index 000000000..7ff8b5b13 --- /dev/null +++ b/app/assets/javascripts/initializers/initializeTimeFixer.js @@ -0,0 +1,70 @@ +function initializeTimeFixer() { + var utcTime = document.getElementsByClassName('utc-time'); + var utcDate = document.getElementsByClassName('utc-date'); + var utc = document.getElementsByClassName('utc'); + + if (!utc) { + return; + } + + function convertUtcTime(utcTime) { + var time = new Date(utcTime); + var options = { + hour: 'numeric', + minute: 'numeric', + }; + time = new Intl.DateTimeFormat('en-US', options).format(time); + return time; + } + + function updateLocalTime(times) { + var localTime; + for (var i = 0; i < times.length; i++) { + localTime = convertUtcTime(times[i].innerHTML); + times[i].innerHTML = localTime; + } + } + + function convertUtcDate(utcDate) { + var date = new Date(utcDate); + var options = { + month: 'short', + day: 'numeric', + }; + date = new Intl.DateTimeFormat('en-US', options).format(date); + return date; + } + + function updateLocalDate(dates) { + var localDate; + for (var i = 0; i < dates.length; i++) { + localDate = convertUtcDate(dates[i].innerHTML); + dates[i].innerHTML = localDate; + } + } + + function convertCalEvent(utc) { + var date = new Date(utc); + var options = { + weekday: 'long', + month: 'long', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + }; + date = new Intl.DateTimeFormat('en-US', options).format(date); + return date; + } + + function updateCalendarTime(utcTimes) { + var calTime; + for (var i = 0; i < utcTimes.length; i++) { + calTime = convertCalEvent(utcTimes[i].innerHTML); + utcTimes[i].innerHTML = calTime; + } + } + + updateLocalTime(utcTime); + updateLocalDate(utcDate); + updateCalendarTime(utc); +} diff --git a/app/assets/javascripts/utilities/getLocalTime.js b/app/assets/javascripts/utilities/getLocalTime.js new file mode 100644 index 000000000..4da57bb48 --- /dev/null +++ b/app/assets/javascripts/utilities/getLocalTime.js @@ -0,0 +1,15 @@ +function updateLocalTime(times) { + function convertUtcTime(timestamp) { + var time = new Date(timestamp); + var options = { + hour: 'numeric', + minute: 'numeric', + }; + time = new Intl.DateTimeFormat('en-US', options).format(time); + return time; + } + for (var i = 0; i < times.length; i++) { + localTime = convertUtcTime(times[i].innerHTML); + times[i].innerHTML = localTime; + } +} diff --git a/app/views/articles/_sidebar_additional.html.erb b/app/views/articles/_sidebar_additional.html.erb index 1ad69759b..c76bf769a 100644 --- a/app/views/articles/_sidebar_additional.html.erb +++ b/app/views/articles/_sidebar_additional.html.erb @@ -95,6 +95,21 @@ <% end %> + <% if Event.in_the_future_and_published.any? && Flipflop.upcoming_events? %> +
+
+ upcoming live events +
+
+ + VIEW ALL EVENTS +
+
+ <% end %> <% if Article.active_help.any? %>
diff --git a/app/views/events/_event.html.erb b/app/views/events/_event.html.erb index 1d7a72ce3..bf1707614 100644 --- a/app/views/events/_event.html.erb +++ b/app/views/events/_event.html.erb @@ -2,7 +2,7 @@ .container .event { padding: 20px; border: solid 2px #66e2d5;; - border-radius: 3px; + border-radius: 3px; margin: 50px auto; box-shadow: 5px 8px 0px #ccfff9; font-size: 17px; @@ -24,7 +24,7 @@ } .event .event-details p { margin: 5px; - } + } .event .event-description p { text-align: justify; @@ -33,8 +33,8 @@ margin: 0 0 .5em 0; font-weight: 800; font-size: 1.11em; - } - + } + @media screen and (max-width: 900px) { .container .body .event .event-image { display: block; @@ -45,7 +45,7 @@ .copyx{ display: none !important; } - .addeventatc {visibility:hidden;} + .addeventatc {visibility:hidden;}
@@ -55,18 +55,16 @@

<%= event.category %>: <%= event.title %>

- <% if !event.cover_image.present? %> - Date: <%= event.starts_at.in_time_zone('Eastern Time (US & Canada)').strftime("%b %d %Y") %> -
- <% end %> - Time: <%= event.starts_at.in_time_zone('Eastern Time (US & Canada)').to_formatted_s(:time) %> - <%= event.ends_at.in_time_zone('Eastern Time (US & Canada)').to_formatted_s(:time) %> EDT + Date: <%= event.starts_at %>
- Location: <%= event.location_name %> + Time: <%= event.starts_at %> - <%= event.ends_at %> +
+ Location: <%= event.location_name %>

Add to Calendar - <%= event.starts_at.in_time_zone('Eastern Time (US & Canada)').strftime("%m/%d/%Y") %> <%= event.starts_at.in_time_zone('Eastern Time (US & Canada)').to_formatted_s(:time) %> - <%= event.ends_at.in_time_zone('Eastern Time (US & Canada)').strftime("%m/%d/%Y") %> <%= event.ends_at.in_time_zone('Eastern Time (US & Canada)').to_formatted_s(:time) %> + <%= event.starts_at %> + <%= event.ends_at %> America/New_York <%= event.title %> The DEV Community @@ -77,20 +75,19 @@ <%= event.description_html.html_safe %> ------ - - Link to attend - <%= event.location_url%> + Link to attend - <%= event.location_url%>
<%= event.description_html.html_safe %> -
+
- \ No newline at end of file + \ No newline at end of file diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 204ab2167..a889eb40f 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -40,10 +40,9 @@

PAST
EVENTS

- + <% @past_events.each do |event|%> <%= render 'event', event: event %> <% end %> - - + \ No newline at end of file diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index b38a3f4a6..62cecdac3 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -51,7 +51,7 @@ } .container .event .event-details { font-size: 1.3em; - } + } .addeventatc { border: solid 1px #66e2d5; } diff --git a/config/features.rb b/config/features.rb index a98f0f407..09677c765 100644 --- a/config/features.rb +++ b/config/features.rb @@ -31,4 +31,7 @@ Flipflop.configure do feature :sendbird, default: true, description: "Toggle between Sendbird and our custom chat" + feature :upcoming_events, + default: true, + description: "Toggle upcoming events in sidebar" end