meetalendar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rubocop.yml +96 -0
  4. data/.travis.yml +21 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE +20 -0
  7. data/README.md +141 -0
  8. data/Rakefile +5 -0
  9. data/app/controllers/comfy/admin/meetalendar/meetups_controller.rb +154 -0
  10. data/app/models/comfy/admin/meetalendar/auth_credential.rb +22 -0
  11. data/app/models/comfy/admin/meetalendar/meetup_group.rb +3 -0
  12. data/app/models/comfy/admin/meetalendar/meetups_calendar_syncer.rb +178 -0
  13. data/app/models/comfy/admin/meetalendar/meetups_controller_logic.rb +77 -0
  14. data/app/models/google/auth/store/db_token_store.rb +37 -0
  15. data/app/views/comfy/admin/meetalendar/meetups/_authorize_calendar.slim +6 -0
  16. data/app/views/comfy/admin/meetalendar/meetups/_edit.slim +6 -0
  17. data/app/views/comfy/admin/meetalendar/meetups/_search_mask.slim +19 -0
  18. data/app/views/comfy/admin/meetalendar/meetups/_search_result.slim +57 -0
  19. data/app/views/comfy/admin/meetalendar/meetups/authorize_calendar.slim +6 -0
  20. data/app/views/comfy/admin/meetalendar/meetups/edit.slim +11 -0
  21. data/app/views/comfy/admin/meetalendar/meetups/index.slim +26 -0
  22. data/app/views/comfy/admin/meetalendar/meetups/search_mask.slim +5 -0
  23. data/app/views/comfy/admin/meetalendar/meetups/search_result.slim +5 -0
  24. data/app/views/comfy/admin/meetalendar/partials/_navigation.html.haml +9 -0
  25. data/app/views/layouts/comfy/meetalendar/application.html.erb +28 -0
  26. data/bin/bundle +3 -0
  27. data/bin/rails +4 -0
  28. data/bin/rake +4 -0
  29. data/bin/setup +36 -0
  30. data/bin/update +31 -0
  31. data/bin/yarn +11 -0
  32. data/comfy_meetalendar.gemspec +44 -0
  33. data/config.ru +6 -0
  34. data/config/application.rb +38 -0
  35. data/config/boot.rb +7 -0
  36. data/config/database.yml +11 -0
  37. data/config/environment.rb +7 -0
  38. data/config/environments/development.rb +64 -0
  39. data/config/environments/test.rb +51 -0
  40. data/config/initializers/meetalendar.rb +23 -0
  41. data/config/locales/en.yml +33 -0
  42. data/config/meetalendar_routes.rb +3 -0
  43. data/config/storage.yml +35 -0
  44. data/db/migrate/00_create_cms.rb +142 -0
  45. data/db/migrate/01_create_meetalendar_meetup_groups.rb +13 -0
  46. data/db/migrate/02_create_meetalendar_auth_credentials.rb +16 -0
  47. data/lib/generators/comfy/meetalendar/README +5 -0
  48. data/lib/generators/comfy/meetalendar/meetalendar_generator.rb +61 -0
  49. data/lib/meetalendar.rb +29 -0
  50. data/lib/meetalendar/configuration.rb +24 -0
  51. data/lib/meetalendar/engine.rb +32 -0
  52. data/lib/meetalendar/routes/meetalendar_admin.rb +30 -0
  53. data/lib/meetalendar/routing.rb +3 -0
  54. data/lib/meetalendar/version.rb +7 -0
  55. data/lib/tasks/meetalendar_tasks.rake +14 -0
  56. metadata +244 -0
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ h2 Find new Meetup Groups
3
+
4
+ = comfy_form_with url: :search_result_comfy_admin_meetalendar_meetups, method: :get do |search_mask|
5
+ = render 'search_mask', form: search_mask
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ h2= 'Found Meetup Groups'
3
+
4
+ = comfy_form_with model: @meetup, url: { controller: "comfy/admin/meetalendar/meetups", action: "create" } do |search_result|
5
+ = render 'search_result', form: search_result
@@ -0,0 +1,9 @@
1
+ -# - if @site && @site.persisted?
2
+ -# %li.nav-item
3
+ -# = active_link_to comfy_admin_meetalendar_meetups_path(@site), class: "nav-link" do
4
+ -# = t('comfy.admin.cms.base.meetups')
5
+
6
+ - if @site && @site.persisted?
7
+ %li.nav-item
8
+ = active_link_to comfy_admin_meetalendar_meetups_path(@site), class: "nav-link" do
9
+ = t('comfy.admin.cms.base.meetups')
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Meetalendar</title>
5
+ <!-- Required meta tags -->
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8
+
9
+ <!-- Bootstrap CSS -->
10
+ <%# <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> %>
11
+
12
+ <%= csrf_meta_tags %>
13
+ <%= csp_meta_tag %>
14
+
15
+ <%= stylesheet_link_tag "meetalendar/application", media: "all" %>
16
+ <%= javascript_include_tag "meetalendar/application" %>
17
+ </head>
18
+ <body>
19
+
20
+ <%= yield %>
21
+
22
+ <!-- Optional JavaScript -->
23
+ <!-- jQuery first, then Popper.js, then Bootstrap JS -->
24
+ <%# <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
25
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
26
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script> %>
27
+ </body>
28
+ </html>
data/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
data/bin/setup ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a starting point to setup your application.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
data/bin/update ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
data/bin/yarn ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(' ')}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
4
+
5
+ require "meetalendar/version"
6
+
7
+ # Describe your gem and declare its dependencies:
8
+ Gem::Specification.new do |s|
9
+ s.name = "meetalendar"
10
+ s.version = Meetalendar::VERSION
11
+ s.authors = ["Andreas Schau @ HicknHack"]
12
+ s.email = ["andreas.schau@hicknhack-software.com"]
13
+ s.homepage = "https://www.hicknhack-software.com/"
14
+ s.summary = "To have a section on a website that allows gathering of meetup groups. So that their events can regularely be syncronized into a google calendar."
15
+ s.description = "This gem prensents all the needed functionality to search for relevant groups on meetup, remember the chosen ones and offers a task that can be called regularely to transcribe the meetup-groups events to a google calendar. TLDR: It allows the user to subscribe to meetup-groups events."
16
+ s.license = "MIT"
17
+
18
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|doc)/})
20
+ end
21
+
22
+ s.require_paths = ["lib"]
23
+
24
+ s.required_ruby_version = ">= 2.3.0"
25
+
26
+ s.add_dependency 'rails', '~> 5.2', '>= 5.2.2'
27
+
28
+ # httpclient for manual auth calls
29
+ s.add_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
30
+
31
+ # google api for calendar event insetion
32
+ s.add_dependency 'google-api-client', '~> 0.30.3'
33
+
34
+ # helps encrypt and decrypt tokens from the database
35
+ s.add_dependency 'attr_encrypted', '~> 3.1'
36
+
37
+ # helps with exceptions
38
+ s.add_dependency 'activeresource', '~> 5.1'
39
+
40
+ # Asset processors
41
+ s.add_dependency 'slim', '~> 4.0', '>= 4.0.1'
42
+ s.add_dependency 'multi_json', '~> 1.13', '>= 1.13.1'
43
+ s.add_dependency 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
44
+ end
data/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require ::File.expand_path("../config/environment", __FILE__)
6
+ run Meetalendar::Application
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "boot"
4
+
5
+ require "rails/all"
6
+
7
+ # Require the gems listed in Gemfile, including any gems
8
+ # you've limited to :test, :development, or :production.
9
+ Bundler.require(*Rails.groups)
10
+
11
+ module Meetalendar
12
+ class Application < Rails::Application
13
+
14
+ require_relative "../lib/meetalendar"
15
+
16
+ config.load_defaults 5.2
17
+
18
+ # Settings in config/environments/* take precedence over those specified here.
19
+ # Application configuration should go into files in config/initializers
20
+ # -- all .rb files in that directory are automatically loaded.
21
+
22
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
23
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
24
+ # config.time_zone = 'Central Time (US & Canada)'
25
+
26
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
27
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
28
+ # config.i18n.default_locale = :de
29
+
30
+ # Ensuring that all ActiveStorage routes are loaded before out globbing route.
31
+ config.railties_order = [ActiveStorage::Engine, :main_app, :all]
32
+
33
+ # Making sure we don't load our dev routes as part of the engine
34
+ config.paths["config/routes.rb"] << "config/meetalendar_routes.rb"
35
+
36
+ config.i18n.enforce_available_locales = true
37
+ end
38
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
5
+
6
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
7
+ File.exist?(ENV["BUNDLE_GEMFILE"])
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ pool: 5
5
+ timeout: 10000
6
+
7
+ test:
8
+ adapter: sqlite3
9
+ database: db/test.sqlite3
10
+ pool: 5
11
+ timeout: 10000
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the rails application
4
+ require File.expand_path("application", __dir__)
5
+
6
+ # Initialize the rails application
7
+ Meetalendar::Application.initialize!
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ defined?(Meetalendar::Application) && Meetalendar::Application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded on
7
+ # every request. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable/disable caching. By default caching is disabled.
18
+ # Run rails dev:cache to toggle caching.
19
+ if Rails.root.join("tmp/caching-dev.txt").exist?
20
+ config.action_controller.perform_caching = true
21
+
22
+ config.cache_store = :memory_store
23
+ config.public_file_server.headers = {
24
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
25
+ }
26
+ else
27
+ config.action_controller.perform_caching = false
28
+
29
+ config.cache_store = :null_store
30
+ end
31
+
32
+ # Store uploaded files on the local file system (see config/storage.yml for options)
33
+ config.active_storage.service = :local
34
+
35
+ # Don't care if the mailer can't send.
36
+ config.action_mailer.raise_delivery_errors = false
37
+
38
+ config.action_mailer.perform_caching = false
39
+
40
+ # Print deprecation notices to the Rails logger.
41
+ config.active_support.deprecation = :log
42
+
43
+ # Raise an error on page load if there are pending migrations.
44
+ config.active_record.migration_error = :page_load
45
+
46
+ # Debug mode disables concatenation and preprocessing of assets.
47
+ # This option may cause significant delays in view rendering with a large
48
+ # number of complex assets.
49
+ config.assets.debug = true
50
+
51
+ # Suppress logger output for asset requests.
52
+ config.assets.quiet = true
53
+
54
+ # Raises error for missing translations
55
+ # config.action_view.raise_on_missing_translations = true
56
+
57
+ # Use an evented file watcher to asynchronously detect changes in source code,
58
+ # routes, locales, etc. This feature depends on the listen gem.
59
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
60
+
61
+ config.active_job.queue_adapter = :inline
62
+
63
+ config.action_view.raise_on_missing_translations = true
64
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ defined?(Meetalendar::Application) && Meetalendar::Application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+ config.cache_classes = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Configure public file server for tests with Cache-Control for performance.
18
+ config.public_file_server.enabled = true
19
+ config.public_file_server.headers = {
20
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
21
+ }
22
+
23
+ # Show full error reports and disable caching.
24
+ config.consider_all_requests_local = true
25
+ config.action_controller.perform_caching = false
26
+
27
+ # Raise exceptions instead of rendering exception templates.
28
+ config.action_dispatch.show_exceptions = false
29
+
30
+ # Disable request forgery protection in test environment.
31
+ config.action_controller.allow_forgery_protection = false
32
+
33
+ # Store uploaded files on the local file system in a temporary directory
34
+ config.active_storage.service = :test
35
+ config.action_mailer.perform_caching = false
36
+
37
+ # Tell Action Mailer not to deliver emails to the real world.
38
+ # The :test delivery method accumulates sent emails in the
39
+ # ActionMailer::Base.deliveries array.
40
+ config.action_mailer.delivery_method = :test
41
+
42
+ # Print deprecation notices to the stderr.
43
+ config.active_support.deprecation = :stderr
44
+
45
+ # Raises error for missing translations
46
+ # config.action_view.raise_on_missing_translations = true
47
+
48
+ config.active_job.queue_adapter = :inline
49
+
50
+ config.action_view.raise_on_missing_translations = true
51
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "googleauth"
4
+
5
+ Meetalendar.configure do |config|
6
+ # application layout to be used to index blog posts
7
+ # config.app_layout = 'comfy/meetalendar/application'
8
+
9
+ # Number of posts per page. Default is 10
10
+ # config.posts_per_page = 10
11
+
12
+ # Loading credentials for the meelanedar functionality
13
+ ENV_MEETALENDAR_CREDENTIALS_FILEPATH ||= "MEETALENDAR_CREDENTIALS_FILEPATH".freeze
14
+ Rails.logger.error("#{ENV_MEETALENDAR_CREDENTIALS_FILEPATH} is not set but needed!") if !ENV.has_key?(ENV_MEETALENDAR_CREDENTIALS_FILEPATH)
15
+ MEETALENDAR_CREDENTIALS_FILEPATH ||= Comfy::Admin::Meetalendar::AuthCredential.expand_env(ENV[ENV_MEETALENDAR_CREDENTIALS_FILEPATH].to_s)
16
+
17
+ File.open MEETALENDAR_CREDENTIALS_FILEPATH.to_s do |file|
18
+ json = file.read
19
+ all_credentials = MultiJson.load json
20
+ MEETALENDAR_CREDENTIALS_MEETUP ||= all_credentials["meetup"]
21
+ MEETALENDAR_CREDENTIALS_GOOGLE_CALENDAR_CLIENT_ID ||= Google::Auth::ClientId.from_hash all_credentials["google_calendar"]
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at http://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"