tkh_events 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b49b02c58f06ce342d2b0e894e49282cb2f63da
4
+ data.tar.gz: 2daafbd202ae95425fd7408ccfa3d1bbe7908161
5
+ SHA512:
6
+ metadata.gz: 73e243abdff5c38e8bc18b51060171f1094fe9a51deba2bda5151448f5c18b82133e3dfc5a3138f43dad405e236ea8075e64da9ab89f7e37bd2c502452cd06d6
7
+ data.tar.gz: 7067cd2e60e324ef5ddc84d434c520db7f933a579c74ce2de248d38796a3ad0a90568d16ee9ae88a76f33ee9d61e05c793ef5c50132cfdf10e8da032f2e870df
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.5
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tkh_events.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # TkhEvents
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tkh_events'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tkh_events
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/tkh_events/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ task :default => :test
9
+
@@ -0,0 +1,74 @@
1
+ class EventsController < ApplicationController
2
+
3
+ before_filter :authenticate, :except => 'show'
4
+ before_filter :authenticate_with_admin, :except => 'show'
5
+
6
+ before_action :set_event, only: [ :show, :edit, :update, :destroy ]
7
+
8
+ def index
9
+ @events = Event.by_recent
10
+ switch_to_admin_layout
11
+ end
12
+
13
+ def show
14
+ end
15
+
16
+ def new
17
+ @event = Event.new
18
+ switch_to_admin_layout
19
+ end
20
+
21
+ def edit
22
+ switch_to_admin_layout
23
+ end
24
+
25
+ def create
26
+ @event = Event.new(event_params)
27
+
28
+ respond_to do |format|
29
+ if @event.save
30
+ format.html { redirect_to @event, notice: 'Event was successfully created.' }
31
+ format.json { render action: 'show', status: :created, location: @event }
32
+ else
33
+ format.html { render action: 'new' }
34
+ format.json { render json: @event.errors, status: :unprocessable_entity }
35
+ end
36
+ end
37
+ end
38
+
39
+ def update
40
+ respond_to do |format|
41
+ if @event.update(event_params)
42
+ format.html { redirect_to @event, notice: 'Event was successfully updated.' }
43
+ format.json { head :no_content }
44
+ else
45
+ format.html { render action: 'edit' }
46
+ format.json { render json: @event.errors, status: :unprocessable_entity }
47
+ end
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ @event.destroy
53
+ respond_to do |format|
54
+ format.html { redirect_to events_url }
55
+ format.json { head :no_content }
56
+ end
57
+ end
58
+
59
+ def duplicate
60
+ Event.duplicate(params[:id])
61
+ redirect_to events_path, notice: 'Your event has been duplicated.'
62
+ end
63
+
64
+ private
65
+ # Use callbacks to share common setup or constraints between actions.
66
+ def set_event
67
+ @event = Event.find(params[:id])
68
+ end
69
+
70
+ # Never trust parameters from the scary internet, only allow the white list through.
71
+ def event_params
72
+ params.require(:event).permit(:name, :description, :body, :starts_at, :published)
73
+ end
74
+ end
@@ -0,0 +1,26 @@
1
+ class Event < ActiveRecord::Base
2
+
3
+ tkh_searchable
4
+ def self.tkh_search_indexable_fields
5
+ indexable_fields = {
6
+ name: 8,
7
+ description: 3,
8
+ body: 2
9
+ }
10
+ end
11
+
12
+ def to_param
13
+ name ? "#{id}-#{name.to_url}" : id
14
+ end
15
+
16
+ scope :published, -> { where( published: true ) }
17
+ scope :by_recent, -> { order('updated_at desc') }
18
+
19
+ def self.duplicate( source_event_id )
20
+ old_event = find( source_event_id )
21
+ new_event = old_event.dup
22
+ new_event.name = "Copy of #{old_event.name}"
23
+ new_event.save
24
+ end
25
+
26
+ end
@@ -0,0 +1,14 @@
1
+ <% if administrator? %>
2
+
3
+ <% content_for :admin_context_menu do %>
4
+
5
+ <h2><%= t('admin_section') %></h2>
6
+ <ul class="list-group">
7
+ <li class="list-group-item"><%= link_to t('admin_panel'), events_path %></li>
8
+ <%= content_tag :li, link_to( "#{t('activerecord.models.comments').capitalize} <span class='badge'>#{Comment.pending.count}</span>".html_safe, pending_comments_path ), class: 'list-group-item' if Comment.pending.count > 0 %>
9
+ <li class="list-group-item"><%= link_to 'Modify this program', edit_event_path(event) %></li>
10
+ </ul>
11
+
12
+ <% end -%>
13
+
14
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ <%= simple_form_for(@event, :html => { class: 'form-horizontal' }) do |f| %>
2
+ <%= f.error_notification %>
3
+
4
+ <%= f.input :name, input_html: { size: 45 } %>
5
+ <%= f.input :starts_at %>
6
+ <%= f.input :published %>
7
+ <%= f.input :description, :input_html => { cols: 45, rows: 3 } %>
8
+ <%= f.input :body, :input_html => { rows: 20, class: 'ckeditor' } %>
9
+ <br />
10
+ <%= f.button :submit, class: 'btn btn-primary' %>
11
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <ul class="nav nav-tabs" id="admin-menu-tab">
2
+ <%= content_tag :li, link_to(t('new'), new_event_path), ({ class: 'active' } if controller.action_name.to_s == 'new' ) %>
3
+ <%= content_tag :li, link_to(t('list'), events_path), ({ class: 'active' } if controller.action_name.to_s == 'index' ) %>
4
+ <%= content_tag :li, link_to(t('edit'), '#'), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
5
+ </ul>
@@ -0,0 +1,7 @@
1
+ <h1>Workshops & Upcoming Events</h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
4
+
5
+ <%= render 'form', event: @event %>
6
+
7
+ <%= render '/shared/admin_sidebar' %>
@@ -0,0 +1,32 @@
1
+ <h1>Workshops & Upcoming Events</h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
4
+
5
+ <table class='table table-striped'>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Starting on</th>
10
+ <th><%= t('actions') %></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% unless @events.nil? %>
16
+ <% for event in @events do %>
17
+ <tr>
18
+ <td><%= link_to event.name, event %></td>
19
+ <td><%= l event.starts_at, format: :tkh_default %></td>
20
+ <td><%= link_to "<span class='glyphicon glyphicon-pencil'></span>".html_safe, edit_event_path(event), :class => 'btn btn-xs btn-default', title: t('edit') %><%= link_to "<span class='glyphicon glyphicon-plus'></span> duplicate".html_safe, duplicate_event_path(event), :class => 'btn btn-xs btn-default', method: :post %></td>
21
+ </tr>
22
+ <% end %>
23
+ <% else %>
24
+ <tr> <td colspan="3">There are no events yet.</td> </tr>
25
+ <% end %>
26
+ </tbody>
27
+
28
+ </table>
29
+
30
+ <%= link_to 'create new', new_event_path, class: 'btn btn-xs btn-default' %>
31
+
32
+ <%= render 'shared/admin_sidebar' %>
@@ -0,0 +1,7 @@
1
+ <h1>Workshops & Upcoming Events</h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
4
+
5
+ <%= render 'form', event: @event %>
6
+
7
+ <%= render '/shared/admin_sidebar' %>
@@ -0,0 +1,13 @@
1
+ <% content_for :meta_title, @event.name %>
2
+ <% content_for :meta_description, @event.description %>
3
+ <% content_for :canonical_link, link_to('', @event, rel: 'canonical') %>
4
+
5
+ <h1><%= @event.name %></h1>
6
+ <p class='event-starting-date'>
7
+ <strong>Starting Date & Time</strong><br />
8
+ <%= l @event.starts_at, format: :tkh_default %>
9
+ </p>
10
+
11
+ <%= raw @event.body %>
12
+
13
+ <%= render( 'admin_context_menu', event: @event) %>
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
3
+ resources :events do
4
+ member { post :duplicate }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module TkhEvents
4
+ module Generators
5
+ class CreateOrUpdateMigrationsGenerator < ::Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "create or update event migrations"
9
+ def self.next_migration_number(path)
10
+ unless @prev_migration_nr
11
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
12
+ else
13
+ @prev_migration_nr += 1
14
+ end
15
+ @prev_migration_nr.to_s
16
+ end
17
+
18
+ def copy_migrations
19
+ puts 'creating or updating event migrations'
20
+ migration_template "create_events.rb", "db/migrate/create_events.rb"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ class CreateEvents < ActiveRecord::Migration
2
+ def change
3
+ create_table :events do |t|
4
+ t.string :name
5
+ t.text :description
6
+ t.text :body
7
+ t.datetime :starts_at
8
+ t.boolean :published, default: false
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ namespace :tkh_events do
2
+ desc "Create migrations and locale files."
3
+ task :install do
4
+ system 'rails g tkh_content:create_or_update_migrations'
5
+ # system 'rails g tkh_content:create_or_update_locales -f'
6
+ end
7
+
8
+ desc "Update files. Skip existing migrations. Force overwrite locales."
9
+ task :update do
10
+ system 'rails g tkh_content:create_or_update_migrations -s'
11
+ # system 'rails g tkh_content:create_or_update_locales -f'
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module TkhEvents
2
+ VERSION = "0.0.1"
3
+ end
data/lib/tkh_events.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "tkh_events/version"
2
+ require "tkh_search"
3
+
4
+ module TkhEvents
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'tkh_events'
3
+
4
+ require 'minitest/autorun'
@@ -0,0 +1,11 @@
1
+ require 'minitest_helper'
2
+
3
+ class TestTkhEvents < MiniTest::Unit::TestCase
4
+ def test_that_it_has_a_version_number
5
+ refute_nil ::TkhEvents::VERSION
6
+ end
7
+
8
+ def test_it_does_something_useful
9
+ assert false
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tkh_events/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tkh_events"
8
+ spec.version = TkhEvents::VERSION
9
+ spec.authors = ["Swami Atma"]
10
+ spec.email = ["swami@TenThousandHours.eu"]
11
+ spec.summary = %q{ Rails engine module for events such as workshops etc. }
12
+ spec.description = %q{ Rails engine module for events such as workshops etc. }
13
+ spec.homepage = "https://github.com/allesklar/tkh_events"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+
25
+ spec.add_dependency 'tkh_search'
26
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tkh_events
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Swami Atma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tkh_search
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: " Rails engine module for events such as workshops etc. "
70
+ email:
71
+ - swami@TenThousandHours.eu
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - app/controllers/events_controller.rb
84
+ - app/models/event.rb
85
+ - app/views/events/_admin_context_menu.html.erb
86
+ - app/views/events/_form.html.erb
87
+ - app/views/events/_tab_admin_menu.html.erb
88
+ - app/views/events/edit.html.erb
89
+ - app/views/events/index.html.erb
90
+ - app/views/events/new.html.erb
91
+ - app/views/events/show.html.erb
92
+ - config/routes.rb
93
+ - lib/generators/tkh_events/create_or_update_migrations/create_or_update_migrations_generator.rb
94
+ - lib/generators/tkh_events/create_or_update_migrations/templates/create_events.rb
95
+ - lib/tasks/tkh_events_tasks.rake
96
+ - lib/tkh_events.rb
97
+ - lib/tkh_events/version.rb
98
+ - test/minitest_helper.rb
99
+ - test/test_tkh_events.rb
100
+ - tkh_events.gemspec
101
+ homepage: https://github.com/allesklar/tkh_events
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Rails engine module for events such as workshops etc.
125
+ test_files:
126
+ - test/minitest_helper.rb
127
+ - test/test_tkh_events.rb