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? %> +
+ <% end %> <% if Article.active_help.any? %> - \ 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 @@