Skip to content

Commit

Permalink
add github references to planning issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phoet committed May 15, 2019
1 parent 2a4f232 commit bd8d945
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 111 deletions.
3 changes: 3 additions & 0 deletions app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ApplicationController < Administrate::ApplicationController
include LocaleDetection
include TimeZoneDetection

helper all_helpers_from_path 'app/helpers'

before_action :authenticate_admin_user!
before_action :setup

Expand All @@ -20,6 +22,7 @@ class ApplicationController < Administrate::ApplicationController
# params[:per_page] || 20
# end


private

def setup
Expand Down
3 changes: 3 additions & 0 deletions app/dashboards/event_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class EventDashboard < Administrate::BaseDashboard
topics: Field::HasMany,
materials: Field::HasMany,
id: Field::Number,
github_issue: Field::Number,
name: Field::String,
date: Field::DateTime,
description: Field::Text,
Expand Down Expand Up @@ -56,6 +57,7 @@ class EventDashboard < Administrate::BaseDashboard
:published,
:label,
:limit,
:github_issue,
].freeze

# FORM_ATTRIBUTES
Expand All @@ -68,6 +70,7 @@ class EventDashboard < Administrate::BaseDashboard
:user,
:location,
:limit,
:github_issue,
:topics,
:materials,
:participants,
Expand Down
36 changes: 25 additions & 11 deletions app/helpers/external_link_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ def link_to_twitter(thing, params = { clung: false }, &block)
end
end

def github_url(path = '')
"https://github.com/#{Whitelabel[:github_org]}/#{Whitelabel[:github_repo]}/#{path}"
end

def github_issue_url(id)
"#{github_url('issues')}/#{id}"
end

def github_new_issue_url
if Whitelabel[:github_issue_template].present?
"#{github_url('issues/new')}?template=#{Whitelabel[:github_issue_template]}"
else
github_url('issues/new')
end
end

def link_to_github(user, &block)
return unless user.github
url = "https://github.com/#{user.github}"
Expand Down Expand Up @@ -89,18 +105,16 @@ def twitter_update_url(model)
"https://twitter.com/home?status=#{URI.encode(text)}"
end

def likes
def github(event)
return unless event.github_issue?

content_tag :span, class: 'likes' do
javascript_include_tag("//apis.google.com/js/plusone.js", "//platform.twitter.com/widgets.js", async: true) +
raw(%(
<g:plusone size="medium"></g:plusone>
<a href="https://twitter.com/share"
class="twitter-share-button"
data-url="#{url_for(only_path: false)}"
data-count="horizontal"
data-via="#{Whitelabel[:twitter]}"
data-lang="#{I18n.locale.downcase}">Tweet</a>
))
raw(
%(
<svg height="20" viewBox="0 0 16 16" version="1.1" width="20" style="margin-bottom: -6px"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
)
) +
link_to('Github Planning Issue', github_issue_url(event.github_issue), target: '_blank')
end
end

Expand Down
5 changes: 4 additions & 1 deletion app/models/usergroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Usergroup

attr_accessor :label_id, :default_locale, :domains, :recurring, :custom_recurring, :email, :google_group, :coc
attr_accessor :default_time_zone, :twitter, :organizers, :location, :imprint, :other_usergroups, :tld
attr_accessor :sponsors, :slackin_url, :country, :status
attr_accessor :sponsors, :slackin_url, :country, :status, :github_org, :github_repo, :github_issue_template

def parse_recurring_date(date)
number, day, = recurring.split(DELIMITER_DATE)
Expand Down Expand Up @@ -104,6 +104,9 @@ def self.from_name(name)
it.domains = ["#{name.parameterize}.de"]
it.recurring = 'second wednesday'
it.email = "info@#{name.parameterize}.de"
it.twitter = name.parameterize
it.github_org = name.parameterize
it.github_repo = 'planning'
it.organizers = ['your_twitter_handle']
it.location = { zoom: 14, lat: 53.079296, long: 8.801694 }
it.imprint = { address: "YourStreet 1\n0815 YourTown", contributors: [{ name: 'Your Name', email: 'your@mail.de' }] }
Expand Down
19 changes: 19 additions & 0 deletions app/views/admin/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ as well as a link to its edit page.
</div>
</header>
<% end %>
<header class="main-content__header" role="banner">
<div>
<% if page.resource.github_issue? %>
<%= link_to(
"See Github-Issue...",
github_issue_url(page.resource.github_issue),
class: "button",
target: '_blank',
) %>
<% else %>
<%= link_to(
"Create Github-Issue...",
github_new_issue_url,
class: "button",
target: '_blank',
) %>
<% end %>
</div>
</header>

<section class="main-content__body">
<dl>
Expand Down
4 changes: 1 addition & 3 deletions app/views/events/show.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
section
= likes
= github(event)
h2#event= event.name
.participation= participation_link(event)
p.meta
Expand Down Expand Up @@ -30,5 +30,3 @@ section
= render 'shared/route', location: event.location

p= link_to t('home.all_events'), events_path


6 changes: 5 additions & 1 deletion app/views/shared/_footer.slim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ section.clearfix
.links.block
h2= t("footer.links")
ul
li= link_to 'GitHub', 'http://github.com/phoet/on_ruby', title: 'Fork me on GitHub'
li
- if Whitelabel[:github_org].present? && Whitelabel[:github_repo].present?
= link_to 'GitHub Organization', github_url, title: 'GitHub Organization'
- else
= link_to 'GitHub', 'http://github.com/phoet/on_ruby', title: 'Fork me on GitHub'
li= link_to 'Mailinglist', mailing_list_url, title: 'Mailinglist'
- if Whitelabel[:coc].present?
li= link_to 'Code of Conduct', Whitelabel[:coc], title: 'Code of Conduct'
Expand Down
3 changes: 3 additions & 0 deletions config/whitelabel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
recurring: second wednesday
email: hamburg@onruby.de
twitter: HamburgOnRuby
github_org: rughh
github_repo: planning
github_issue_template: 'meetup.md'
organizers:
- lindtdev
- janz93
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddGithubIssueToEventAndTopic < ActiveRecord::Migration[6.0]
def change
add_column :events, :github_issue, :integer
add_column :topics, :github_issue, :integer
end
end
Loading

0 comments on commit bd8d945

Please sign in to comment.