Merge master

This commit is contained in:
Ben Halpern 2018-06-19 13:48:10 -04:00
commit bd20390dc8
9 changed files with 131 additions and 30 deletions

View file

@ -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:

View file

@ -40,6 +40,7 @@ function callInitalizers(){
initializeFooterMod();
initializeCommentPreview();
initializeAdditionalContentBoxes();
initializeTimeFixer();
if (!initializeLiveArticle.called){
initializeLiveArticle();
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -95,6 +95,21 @@
</div>
</div>
<% end %>
<% if Event.in_the_future_and_published.any? && Flipflop.upcoming_events? %>
<div class="widget">
<header>
<a href="/events">upcoming live events</a>
</header>
<div class="widget-body">
<div class="widget-link-list">
<% Event.in_the_future_and_published.limit(3).sort_by(&:starts_at).each do |event| %>
<%= render "events/widget_events_item", event: event %>
<% end %>
</div>
<a class="cta cta-button" href="/events">VIEW ALL EVENTS</a>
</div>
</div>
<% end %>
<% if Article.active_help.any? %>
<div class="widget">
<header>

View file

@ -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;}
</style>
<div class="event">
@ -55,18 +55,16 @@
<div class="event-details" >
<h3><a href="/events/<%= event.slug %>"><%= event.category %>: <%= event.title %></a></h3>
<p>
<% if !event.cover_image.present? %>
Date: <%= event.starts_at.in_time_zone('Eastern Time (US & Canada)').strftime("%b %d %Y") %>
<br>
<% 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: <span class="utc-date"><%= event.starts_at %></span>
<br>
Location: <a href="<%= event.location_url %>"><%= event.location_name %></a>
Time: <span class="utc-time"><%= event.starts_at %></span> - <span class="utc-time"><%= event.ends_at %></span>
<br>
Location: <a href="<%= event.location_url %>"><%= event.location_name %></a>
</p>
<div title="Add to Calendar" class="addeventatc">
Add to Calendar
<span class="start"><%= 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) %></span>
<span class="end"><%= 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) %></span>
<span class="start utc"><%= event.starts_at %></span>
<span class="end utc"><%= event.ends_at %></span>
<span class="timezone">America/New_York</span>
<span class="title"><%= event.title %></span>
<span class="organizer">The DEV Community</span>
@ -77,20 +75,19 @@
<span class="description">
<%= event.description_html.html_safe %>
------
Link to attend - <%= event.location_url%>
Link to attend - <%= event.location_url%>
</span>
</div>
</div>
<div class="event-description">
<%= event.description_html.html_safe %>
</div>
</div>
</div>
<script defer>
window.addeventasync = function(){
addeventatc.register('button-dropdown-click', function(obj){
ga('send', 'event', 'click', 'Add Event To Calendar', 'User: <%= user_signed_in? %>');
});
}
</script>
<script defer>
window.addeventasync = function(){
addeventatc.register('button-dropdown-click', function(obj){
ga('send', 'event', 'click', 'Add Event To Calendar', 'User: <%= user_signed_in? %>');
});
}
</script>

View file

@ -40,10 +40,9 @@
<h1 style="font-size:1.9em;font-weight:600;text-align:center;">
PAST <br> EVENTS
</h1>
<% @past_events.each do |event|%>
<%= render 'event', event: event %>
<% end %>
</div>
</div>

View file

@ -51,7 +51,7 @@
}
.container .event .event-details {
font-size: 1.3em;
}
}
.addeventatc {
border: solid 1px #66e2d5;
}

View file

@ -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