From 074d8cdfea04a1451f38be4a03c014851c03407b Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 08:30:22 +0300 Subject: [PATCH 01/29] Add slug field for chapters --- db/migrate/20230403051613_add_slug_to_chapters.rb | 6 ++++++ db/schema.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230403051613_add_slug_to_chapters.rb diff --git a/db/migrate/20230403051613_add_slug_to_chapters.rb b/db/migrate/20230403051613_add_slug_to_chapters.rb new file mode 100644 index 00000000..bbc04095 --- /dev/null +++ b/db/migrate/20230403051613_add_slug_to_chapters.rb @@ -0,0 +1,6 @@ +class AddSlugToChapters < ActiveRecord::Migration[7.0] + def change + add_column :chapters, :slug, :string, null: false + add_index :chapters, :slug, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 34156fca..0e275246 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_13_002939) do +ActiveRecord::Schema[7.0].define(version: 2023_04_03_051613) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -49,7 +49,9 @@ t.bigint "country_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "slug", null: false t.index ["country_id"], name: "index_chapters_on_country_id" + t.index ["slug"], name: "index_chapters_on_slug", unique: true end create_table "countries", force: :cascade do |t| From 75322ba2ba47a166455f48c6801873b6ee509cbb Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 08:36:23 +0300 Subject: [PATCH 02/29] Use slug to retrieve a chapter --- app/controllers/chapters_controller.rb | 3 ++- app/views/chapters/index.html.erb | 30 ++++++++++++++------------ config/routes.rb | 5 ++++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/controllers/chapters_controller.rb b/app/controllers/chapters_controller.rb index 09ecb244..74d2e61a 100644 --- a/app/controllers/chapters_controller.rb +++ b/app/controllers/chapters_controller.rb @@ -1,6 +1,6 @@ class ChaptersController < ApplicationController load_and_authorize_resource except: %i[ index show] # Load cancancan authorize for all actions - before_action :set_chapter, only: %i[ show edit update destroy ] + before_action :set_chapter, only: %i[ edit update destroy ] skip_before_action :authenticate_user!, only: %i[ index show] # GET /chapters or /chapters.json @@ -10,6 +10,7 @@ def index # GET /chapters/1 or /chapters/1.json def show + @chapter = Chapter.find_by_slug(params[:slug]) end # GET /chapters/new diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index b03cd215..0e0400af 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -6,24 +6,26 @@
<% @chapters.each do |chapter| %> - + <% end %> <% end %>
diff --git a/config/routes.rb b/config/routes.rb index bd983110..a341b570 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,10 @@ mount Motor::Admin => '/admin' end resources :projects - resources :chapters + resources :chapters, except: :show do + get ':slug', to: 'chapters#show', as: :find_by_slug, on: :collection + end + resources :countries devise_for :users, controllers: { registrations: 'users/registrations', # Override devise registration controller From 93a2fbbf9fbdd474ffc479b1463d68dcee4e548e Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 08:52:29 +0300 Subject: [PATCH 03/29] Update slug if the chapter name has changed --- app/models/chapter.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/chapter.rb b/app/models/chapter.rb index cbb0a4cb..99cbc7e4 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -16,6 +16,8 @@ class Chapter < ApplicationRecord locals: { country: self }, target: self } after_destroy_commit -> { broadcast_remove_to 'chapters', target: self } + before_validation :update_slug, on: [:create, :update] + # Validations validates :name, :location, :country_id, :description, presence: true validates :name, uniqueness: true @@ -27,4 +29,14 @@ class Chapter < ApplicationRecord # width: 400, height: 225, # message: 'is not given between dimension. It should be 400x225', # } + + private + + ## + # Update slug if the chapter name has changed + def update_slug + if name_changed? + self.slug = name.parameterize(separator: '-') + end + end end From 3456de5cbcf929d17758ddc13b3efdcd1645afec Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 08:52:54 +0300 Subject: [PATCH 04/29] Make slug to be readable only --- config/motor.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/config/motor.yml b/config/motor.yml index 53e043d0..ad0f9991 100644 --- a/config/motor.yml +++ b/config/motor.yml @@ -1,13 +1,15 @@ --- engine_version: 0.4.7 -file_version: 2023-03-09 16:16:17.698355000 Z +file_version: 2023-04-03 05:50:48.235103000 Z resources: - name: chapter preferences: columns: - column_type: richtext name: description - updated_at: 2023-03-05 09:31:13.962854000 +00:00 + - access_type: read_only + name: slug + updated_at: 2023-04-03 05:50:48.235103000 +00:00 - name: feature_flag preferences: columns: @@ -17,16 +19,9 @@ resources: configs: - key: header.links value: - - name: Reports - link_type: reports - - name: Forms - link_type: forms - - conditions: [] - type: header - name: Exit admin portal - path: "/" - link_type: header - updated_at: 2023-03-05 09:37:51.799389000 +00:00 + - name: "⭐ Star on GitHub" + path: https://github.com/motor-admin/motor-admin-rails + updated_at: 2023-03-30 00:41:34.130118000 +00:00 queries: [] dashboards: [] forms: [] @@ -36,5 +31,5 @@ api_configs: name: origin url: "/" preferences: {} - description: - updated_at: 2023-03-05 08:41:14.200426000 +00:00 + description: + updated_at: 2023-03-30 00:41:34.133532000 +00:00 From 51ebab288c2817faefb8ae998b835d532f4a49c8 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 08:59:18 +0300 Subject: [PATCH 05/29] Use slug to grt a chapter --- app/views/chapters/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index 0e0400af..ed717c64 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -6,7 +6,7 @@
<% @chapters.each do |chapter| %> - <%= link_to find_by_slug_chapters_path(chapter.name) do %> + <%= link_to find_by_slug_chapters_path(chapter.slug) do %>
<%= image_tag chapter.image.attached? ? chapter.image.url : image_path('chapter.jpg'), From 044baa63acbce00a795e48569cd865f205b119b2 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 10:08:56 +0300 Subject: [PATCH 06/29] Add 'ActiveStorage::SetCurrent' to allow images to be retrieved from disk --- app/controllers/chapters_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/chapters_controller.rb b/app/controllers/chapters_controller.rb index 74d2e61a..69c847d5 100644 --- a/app/controllers/chapters_controller.rb +++ b/app/controllers/chapters_controller.rb @@ -1,4 +1,6 @@ class ChaptersController < ApplicationController + include ActiveStorage::SetCurrent + load_and_authorize_resource except: %i[ index show] # Load cancancan authorize for all actions before_action :set_chapter, only: %i[ edit update destroy ] skip_before_action :authenticate_user!, only: %i[ index show] From 0c124243c5e883207fad3c5bd7993a212bf8cb62 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Mon, 3 Apr 2023 15:37:57 +0300 Subject: [PATCH 07/29] Style the chapters page --- app/views/chapters/index.html.erb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index ed717c64..4b03ce4a 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -6,26 +6,28 @@
<% @chapters.each do |chapter| %> - <%= link_to find_by_slug_chapters_path(chapter.slug) do %> -
+ <%= link_to find_by_slug_chapters_path(chapter.slug) do %> <%= image_tag chapter.image.attached? ? chapter.image.url : image_path('chapter.jpg'), alt: 'Local meetups photo', class: "rounded-lg rounded-tl-2xl" %> + <% end %> -
+
+ <%= link_to find_by_slug_chapters_path(chapter.slug) do %> <%= chapter.name %> + <% end %> - <% if can? :manage, chapter %> - <%= link_to 'Edit', edit_chapter_path(chapter), class: 'btn btn-xs btn-info', - data: { turbo_frame: "edit_chapter_#{chapter.id}" } %> - <%= link_to 'Delete', chapter, class: 'btn btn-xs btn-error', - method: :delete %> - <% end %> -
+ <% if can? :manage, chapter %> + <%= link_to 'Edit', edit_chapter_path(chapter), class: 'btn btn-xs btn-info', + data: { turbo_frame: "edit_chapter_#{chapter.id}" } %> + <%= link_to 'Delete', chapter, class: 'btn btn-xs btn-error', + method: :delete %> + <% end %>
- <% end %> +
<% end %>
From c268f9026f24c367b9f7f6b75323bacf04f7b8c2 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Fri, 28 Apr 2023 07:44:05 +0300 Subject: [PATCH 08/29] Add email address link to request addition of materials --- app/views/landing/learn.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/landing/learn.html.erb b/app/views/landing/learn.html.erb index 76c070ba..cd23d07c 100644 --- a/app/views/landing/learn.html.erb +++ b/app/views/landing/learn.html.erb @@ -6,7 +6,9 @@

Take a look at our list of resources that can help you get up to speed with the Ruby programming language from the basic building blocks upto to the various frameworks and tools in the Ruby - ecosystem. If you want to add your own resources, fork this repo and send in a pull request. + ecosystem. If you want to add your own resources, email us + at <%= link_to 'organisers@rubycommunity.africa', 'mailto:organisers@rubycommunity.africa', + class: 'text-red-500' %>.

From 5e4c1e1e7f8d6eb2d372cd5792c6b32222a45ddc Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Tue, 2 May 2023 05:56:34 +0300 Subject: [PATCH 09/29] remove edit and delete from chapters index --- .idea/.gitignore | 8 + .idea/arc_platform.iml | 239 ++++++++++++++++++++++++++++++ .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + app/views/chapters/index.html.erb | 7 - db/schema.rb | 13 ++ 7 files changed, 278 insertions(+), 7 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/arc_platform.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/arc_platform.iml b/.idea/arc_platform.iml new file mode 100644 index 00000000..ccfd4189 --- /dev/null +++ b/.idea/arc_platform.iml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..a21b452c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..1fed7715 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/views/chapters/index.html.erb b/app/views/chapters/index.html.erb index d97636d8..df23352c 100644 --- a/app/views/chapters/index.html.erb +++ b/app/views/chapters/index.html.erb @@ -19,13 +19,6 @@ <%= link_to find_by_slug_chapters_path(chapter.slug) do %> <%= chapter.name %> <% end %> - - <% if can? :manage, chapter %> - <%= link_to 'Edit', edit_chapter_path(chapter), class: 'btn btn-xs btn-info', - data: { turbo_frame: "edit_chapter_#{chapter.id}" } %> - <%= link_to 'Delete', chapter, class: 'btn btn-xs btn-error', - method: :delete %> - <% end %>

<% end %> diff --git a/db/schema.rb b/db/schema.rb index 0e275246..6ff63c2c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -68,6 +68,17 @@ t.datetime "updated_at", null: false end + create_table "memberships", force: :cascade do |t| + t.bigint "user_id", null: false + t.bigint "chapter_id", null: false + t.datetime "start_date" + t.datetime "end_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["chapter_id"], name: "index_memberships_on_chapter_id" + t.index ["user_id"], name: "index_memberships_on_user_id" + end + create_table "motor_alert_locks", force: :cascade do |t| t.bigint "alert_id", null: false t.string "lock_timestamp", null: false @@ -313,6 +324,8 @@ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" + add_foreign_key "memberships", "chapters" + add_foreign_key "memberships", "users" add_foreign_key "motor_alert_locks", "motor_alerts", column: "alert_id" add_foreign_key "motor_alerts", "motor_queries", column: "query_id" add_foreign_key "motor_note_tag_tags", "motor_note_tags", column: "tag_id" From 55867a214c2c6eb7c4499f46ab22c7c5cdfb4f5f Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Tue, 2 May 2023 06:00:44 +0300 Subject: [PATCH 10/29] Delete IDE generated files --- .idea/.gitignore | 8 -- .idea/arc_platform.iml | 239 ----------------------------------------- .idea/misc.xml | 4 - .idea/modules.xml | 8 -- .idea/vcs.xml | 6 -- 5 files changed, 265 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/arc_platform.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/arc_platform.iml b/.idea/arc_platform.iml deleted file mode 100644 index ccfd4189..00000000 --- a/.idea/arc_platform.iml +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a21b452c..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 1fed7715..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From c7d2f295d2ba9fc6ebacbd60fd1c5f09fdbc6f99 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Tue, 2 May 2023 06:22:50 +0300 Subject: [PATCH 11/29] Delete unused code --- app/views/chapters/show.html.erb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index cc5251ec..e69de29b 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -1,10 +0,0 @@ -

<%= notice %>

- -<%= render @chapter %> - -
- <%= link_to "Edit this chapter", edit_chapter_path(@chapter) %> | - <%= link_to "Back to chapters", chapters_path %> - - <%= button_to "Destroy this chapter", @chapter, method: :delete %> -
From 31f1f896c6c9ddf2d8c9262c7e5f1358d66ae902 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 03:43:42 +0300 Subject: [PATCH 12/29] Add active storage hero image to chapter --- app/models/chapter.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/chapter.rb b/app/models/chapter.rb index 99cbc7e4..dd6a8852 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -1,6 +1,7 @@ class Chapter < ApplicationRecord # Attachments has_one_attached :image + has_one_attached :hero_image # Associations belongs_to :country From fb64a446c24fc908d1847d3d794e9aab0300e297 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 03:44:31 +0300 Subject: [PATCH 13/29] Add a chapter hero image location design --- app/views/chapters/show.html.erb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index e69de29b..fe9ccd1f 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -0,0 +1,19 @@ +
+
+
+ <% if @chapter.hero_image.present? %> + <%= image_tag(@chapter.hero_image, class: 'rounded-lg w-full h-72 object-cover') %> + <% end %> +
+
+ location +
+
+

+ <%= @chapter.name %> +

+

About Chapter

+
+ <%= sanitize(@chapter.description) %> +
+
From 6d82a0f8bc4f8cb9817cec7cdb0d2141fe587496 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 03:58:06 +0300 Subject: [PATCH 14/29] Add hero image placeholder to chapter Use a placeholder if hero image not attached --- app/views/chapters/show.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index fe9ccd1f..8127dc36 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -3,6 +3,10 @@
<% if @chapter.hero_image.present? %> <%= image_tag(@chapter.hero_image, class: 'rounded-lg w-full h-72 object-cover') %> + <% else %> +
+

No hero image attached

+
<% end %>
From d5af853a353ec6d843e35ecfd84e1539f20c7f42 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Wed, 3 May 2023 04:19:29 +0300 Subject: [PATCH 15/29] To improve: Add a static map for chapter --- app/views/chapters/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index 8127dc36..491261e4 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -10,7 +10,7 @@ <% end %>
- location +

From 209c988cabf37ea9f5e4fecd1d38e79c47128964 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Wed, 3 May 2023 05:32:22 +0300 Subject: [PATCH 16/29] Update Google map iframe code --- app/views/chapters/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index 491261e4..b1e23a36 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -10,7 +10,7 @@ <% end %>
-
+

From 2103d6d1fb9c333daba111ccdcd0107a8ce87654 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 12:15:45 +0300 Subject: [PATCH 17/29] add method to encode the chapter location --- app/models/chapter.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/chapter.rb b/app/models/chapter.rb index dd6a8852..9ba5f0e1 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -31,6 +31,10 @@ class Chapter < ApplicationRecord # message: 'is not given between dimension. It should be 400x225', # } + def encode_address + Addressable::URI.encode(self.location) + end + private ## From c4d7177fb1c0922a7269caf2a3411c129a44ef56 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 12:16:25 +0300 Subject: [PATCH 18/29] Add dynamic location to the map --- app/views/chapters/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index b1e23a36..c2deec7f 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -10,7 +10,7 @@ <% end %>
-
+

From 653ab749d930d7e6667acb5ab15edbbf95a7f8c6 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 21:01:23 +0300 Subject: [PATCH 19/29] Add col leader to users chapter table --- db/migrate/20230503174505_add_leader_to_users_chapter.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230503174505_add_leader_to_users_chapter.rb diff --git a/db/migrate/20230503174505_add_leader_to_users_chapter.rb b/db/migrate/20230503174505_add_leader_to_users_chapter.rb new file mode 100644 index 00000000..2d036805 --- /dev/null +++ b/db/migrate/20230503174505_add_leader_to_users_chapter.rb @@ -0,0 +1,5 @@ +class AddLeaderToUsersChapter < ActiveRecord::Migration[7.0] + def change + add_column :users_chapters, :leader, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 6ff63c2c..726a1772 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_04_03_051613) do +ActiveRecord::Schema[7.0].define(version: 2023_05_03_174505) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -318,6 +318,7 @@ t.boolean "main_chapter", default: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "leader", default: false t.index ["chapter_id"], name: "index_users_chapters_on_chapter_id" t.index ["user_id"], name: "index_users_chapters_on_user_id" end From 5cfc053727f67aea2b96e75f8e1098a2e23e0015 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 21:03:11 +0300 Subject: [PATCH 20/29] Add find by chapter method to users chapter Add method that finds chapter leaders --- app/models/users_chapter.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/users_chapter.rb b/app/models/users_chapter.rb index 693e2f43..5a7ed6a7 100644 --- a/app/models/users_chapter.rb +++ b/app/models/users_chapter.rb @@ -2,4 +2,9 @@ class UsersChapter < ApplicationRecord # Associations belongs_to :chapter belongs_to :user + + def self.find_by_chapter(chapter_id) + users_chapter = find_by(chapter_id: chapter_id, leader: true) + users_chapter&.user&.name || 'No Leader yet' + end end From e7de5402322c7248a0f68fbc1137f664364d7ecd Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Wed, 3 May 2023 21:03:50 +0300 Subject: [PATCH 21/29] Add chapter leaders to chapter view --- app/views/chapters/show.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index c2deec7f..d74567c2 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -20,4 +20,8 @@
<%= sanitize(@chapter.description) %>
+

Chapter Leaders

+
+ <%= UsersChapter.find_by_chapter(@chapter.id) %> +
From 707d85c9f220f5e757f8f51e4751b8ad1a398b46 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Thu, 4 May 2023 03:33:31 +0300 Subject: [PATCH 22/29] Add chapter location to map --- app/views/chapters/show.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index d74567c2..e7b259fc 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -10,6 +10,7 @@ <% end %>
+

<%= "#{@chapter.location}, #{@chapter.country.name}" %>

From 3c943c7994511e9dacfe39dbae9aca31c0dcc6a5 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Thu, 4 May 2023 04:33:13 +0300 Subject: [PATCH 23/29] Moved chapter description and leaders Moved chapter description and leaders to col that covers 2/3 of the page while the map resides on the other col --- app/views/chapters/show.html.erb | 44 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index e7b259fc..2a7c6de6 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -1,28 +1,34 @@
- <% if @chapter.hero_image.present? %> - <%= image_tag(@chapter.hero_image, class: 'rounded-lg w-full h-72 object-cover') %> - <% else %> -
-

No hero image attached

-
- <% end %> +
+ <% if @chapter.hero_image.present? %> + <%= image_tag(@chapter.hero_image, class: 'rounded-lg w-full h-72 object-cover') %> + <% else %> +
+

No hero image attached

+
+ <% end %> +
+

+ <%= @chapter.name %> +

+

About Chapter

+
+ <%= sanitize(@chapter.description) %> +
+

Chapter Leaders

+
+ <% if !UsersChapter.find_by(chapter_id: @chapter, leader: true).nil? %> + <%= chapter_leader_card(@chapter) %> + <% else %> +

No Leaders yet

+ <% end %> +
-
+

<%= "#{@chapter.location}, #{@chapter.country.name}" %>

-

- <%= @chapter.name %> -

-

About Chapter

-
- <%= sanitize(@chapter.description) %> -
-

Chapter Leaders

-
- <%= UsersChapter.find_by_chapter(@chapter.id) %> -
From e2f349a73ee5a1d358784a2c45d9a101ac9e4dc7 Mon Sep 17 00:00:00 2001 From: Kihara-Kamotho Date: Thu, 4 May 2023 04:34:43 +0300 Subject: [PATCH 24/29] Added chapter leader card to chapters helper Used to render chapter leader on the chapter show page --- app/helpers/chapters_helper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/helpers/chapters_helper.rb b/app/helpers/chapters_helper.rb index 063540ba..41bbe8ac 100644 --- a/app/helpers/chapters_helper.rb +++ b/app/helpers/chapters_helper.rb @@ -1,2 +1,17 @@ module ChaptersHelper + def chapter_leader_card(chapter) + leader = UsersChapter.find_by(chapter_id: chapter.id, leader: true).user + image_tag = image_tag("https://github.com/#{leader.github_username}.png", size: "207x97") + name = UsersChapter.find_by_chapter(chapter.id) + + content_tag(:div, class: "bg-gray-100 rounded-md shadow-md overflow-hidden inline-block") do + content_tag(:div, class: "h-48") do + image_tag + end + + content_tag(:div, class: "bg-gray-200 px-4 py-2 my-4") do + content_tag(:p, name, class: "text-gray-800 font-bold") + + content_tag(:p, leader.github_username) + end + end + end end From cb75974df0bd56a6f104f34a488ab7bdd35aa3b2 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Wed, 24 May 2023 03:03:57 +0300 Subject: [PATCH 25/29] Schema changed --- db/schema.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 726a1772..485fc23f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_05_03_174505) do +ActiveRecord::Schema[7.0].define(version: 2023_05_10_014204) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -68,15 +68,23 @@ t.datetime "updated_at", null: false end - create_table "memberships", force: :cascade do |t| - t.bigint "user_id", null: false - t.bigint "chapter_id", null: false - t.datetime "start_date" - t.datetime "end_date" + create_table "meetup_events", force: :cascade do |t| + t.string "title" + t.text "description" + t.string "rsvp_link" + t.string "image" + t.datetime "start_time" + t.datetime "end_time" + t.string "venue_name" + t.string "venue_address" + t.bigint "chapter_id" + t.jsonb "venue_coordinates", default: {}, null: false + t.jsonb "data", default: {}, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["chapter_id"], name: "index_memberships_on_chapter_id" - t.index ["user_id"], name: "index_memberships_on_user_id" + t.string "meetup_id" + t.index ["chapter_id"], name: "index_meetup_events_on_chapter_id" + t.index ["meetup_id"], name: "index_meetup_events_on_meetup_id", unique: true end create_table "motor_alert_locks", force: :cascade do |t| @@ -325,8 +333,6 @@ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" - add_foreign_key "memberships", "chapters" - add_foreign_key "memberships", "users" add_foreign_key "motor_alert_locks", "motor_alerts", column: "alert_id" add_foreign_key "motor_alerts", "motor_queries", column: "query_id" add_foreign_key "motor_note_tag_tags", "motor_note_tags", column: "tag_id" From 943fb2099d88266fea76802df7c80599a93db15a Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Sun, 28 May 2023 03:00:11 +0300 Subject: [PATCH 26/29] Add css styles that will be used used in different pages --- app/assets/stylesheets/application.tailwind.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index c746599e..e0e3133f 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -6,6 +6,22 @@ :root { /* Override colors and other variables */ } + + h1 { + @apply text-2xl font-medium; + } + + h2 { + @apply text-xl; + } + + .arc_title { + @apply text-4xl font-bold text-red-600; + } + + .arc_subtitle { + @apply py-2 text-xl font-medium leading-normal; + } } @layer components { From 422cf8992d31471f6e4f57090dc51c853c277cde Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Sun, 28 May 2023 03:03:04 +0300 Subject: [PATCH 27/29] Load the updated design for a chapter show page --- .../stylesheets/application.tailwind.css | 2 +- app/views/chapters/show.html.erb | 252 ++++++++++++++++-- 2 files changed, 225 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index e0e3133f..e8503f23 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -14,7 +14,7 @@ h2 { @apply text-xl; } - + .arc_title { @apply text-4xl font-bold text-red-600; } diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index 2a7c6de6..4ddbb38f 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -1,34 +1,230 @@ -
-
-
-
- <% if @chapter.hero_image.present? %> - <%= image_tag(@chapter.hero_image, class: 'rounded-lg w-full h-72 object-cover') %> - <% else %> -
-

No hero image attached

+
+
+
+
+
+ thumbnail + +
+
+
+
+
+
+
+

Date and Time

+

5.00 PM - 8.00 PM . EAT . June 22, 2023

+ +
+ +
+ +
- <% end %> +
-

- <%= @chapter.name %> -

-

About Chapter

-
- <%= sanitize(@chapter.description) %> +
+ +
+

Vim and Ruby on Rails meetup

+ +
+
+
+

About event

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed + do eiusmod tempor incididunt ut labore et dolore magna aliqua. Dictum sit amet justo + donec enim. Pulvinar mattis nunc sed blandit. Consectetur adipiscing elit duis + tristique. Id interdum velit laoreet id donec. Eros in cursus turpis massa tincidunt + dui. Eget magna fermentum iaculis eu. Ornare quam viverra orci sagittis. Ipsum + suspendisse ultrices gravida dictum fusce. Faucibus scelerisque eleifend donec pretium + vulputate sapien nec sagittis aliquam. Auctor augue mauris augue neque gravida in + fermentum et. Nulla aliquet porttitor lacus luctus accumsan tortor posuere ac ut. Amet + consectetur adipiscing elit pellentesque habitant morbi. Enim neque volutpat ac + tincidunt vitae semper quis.

+
+
+

Speakers

+
+
+
+ + +
+

John Doe

+ + +
+
+
+ + Github
+
+ + Github
+
+
+
+
+ +
+ + +
+

John Doe

+ + +
+
+
+ + Github
+
+ + Github
+
+
+
+
+
+ + +
+

John Doe

+ + +
+
+
+ + Github
+
+ + Github
+
+
+
+
+
+
+
+
+

Question about event?

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + incididunt ut labore et dolore magna aliqua.

+
+
+
+
+

Event Location

+
+
+ + +
+

iHub, Nairobi, Kenya

+
+

5.00 PM - 8.00 PM (EAT)

+

June 22, 2020

+
+
+
+
+
+
+ +
+
-

Chapter Leaders

+
+ +
- <% if !UsersChapter.find_by(chapter_id: @chapter, leader: true).nil? %> - <%= chapter_leader_card(@chapter) %> - <% else %> -

No Leaders yet

- <% end %> +

Other events you may like

+
+ +
+
+
+
+

Kenya - Nairobi

+
+
+ + +
+

Vim and Ruby on Rails

+
+

5.00 PM - 8.00 PM (EAT)

+

June 22, 2020

+
+
+
+
+
+
+
+ +
+
+
+

Kenya - Mombasa

+
+
+ + +
+

How to Ruby

+
+

5.00 PM - 8.00 PM (EAT)

+

June 22, 2020

+
+
+
+
+
+
+
+ +
+
+
+

Kenya - Kisumu

+
+
+ + +
+

Programming

+
+

5.00 PM - 8.00 PM (EAT)

+

June 22, 2020

+
+
+
+
+
+
+
-
-
-

<%= "#{@chapter.location}, #{@chapter.country.name}" %>

-
-
+
-
+
\ No newline at end of file From 87d381fc72f019b33591d0e84556aba4b9db7fe5 Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Sun, 28 May 2023 04:59:29 +0300 Subject: [PATCH 28/29] Update chapter show page UI --- app/models/chapter.rb | 2 +- .../chapters/_chapter_leader_card.html.erb | 20 ++ app/views/chapters/show.html.erb | 206 ++++-------------- 3 files changed, 65 insertions(+), 163 deletions(-) create mode 100644 app/views/chapters/_chapter_leader_card.html.erb diff --git a/app/models/chapter.rb b/app/models/chapter.rb index 9ba5f0e1..47208cda 100644 --- a/app/models/chapter.rb +++ b/app/models/chapter.rb @@ -31,7 +31,7 @@ class Chapter < ApplicationRecord # message: 'is not given between dimension. It should be 400x225', # } - def encode_address + def encoded_address Addressable::URI.encode(self.location) end diff --git a/app/views/chapters/_chapter_leader_card.html.erb b/app/views/chapters/_chapter_leader_card.html.erb new file mode 100644 index 00000000..d482ef20 --- /dev/null +++ b/app/views/chapters/_chapter_leader_card.html.erb @@ -0,0 +1,20 @@ +
+ <%= image_tag("https://github.com/#{user.github_username}.png", + alt: "#{user.name}'s Github photo", + class: 'h-[75] w-full rounded-t-lg bg-slate-200') %> + +
+

<%= user.name %>

+ + + +
+
\ No newline at end of file diff --git a/app/views/chapters/show.html.erb b/app/views/chapters/show.html.erb index 4ddbb38f..59198a28 100644 --- a/app/views/chapters/show.html.erb +++ b/app/views/chapters/show.html.erb @@ -3,8 +3,13 @@
- thumbnail - + <% if @chapter.hero_image.present? %> + <%= image_tag(@chapter.hero_image, class: 'Event_thumbnail h-[200] w-full rounded-s-lg bg-gray-200') %> + <% else %> +
+

+
+ <% end %>
@@ -12,9 +17,12 @@
-

Date and Time

-

5.00 PM - 8.00 PM . EAT . June 22, 2023

-
+

Upcoming event

+ + Click here for + upcoming events. + +
-
+
-

Vim and Ruby on Rails meetup

+

<%= @chapter.name %>

-

About event

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed - do eiusmod tempor incididunt ut labore et dolore magna aliqua. Dictum sit amet justo - donec enim. Pulvinar mattis nunc sed blandit. Consectetur adipiscing elit duis - tristique. Id interdum velit laoreet id donec. Eros in cursus turpis massa tincidunt - dui. Eget magna fermentum iaculis eu. Ornare quam viverra orci sagittis. Ipsum - suspendisse ultrices gravida dictum fusce. Faucibus scelerisque eleifend donec pretium - vulputate sapien nec sagittis aliquam. Auctor augue mauris augue neque gravida in - fermentum et. Nulla aliquet porttitor lacus luctus accumsan tortor posuere ac ut. Amet - consectetur adipiscing elit pellentesque habitant morbi. Enim neque volutpat ac - tincidunt vitae semper quis.

+

About Chapter

+

<%= sanitize(@chapter.description) %>

-

Speakers

+

Chapter Leaders

-
- - -
-

John Doe

- - -
-
-
- - Github
-
- - Github
-
-
-
-
- -
- - -
-

John Doe

- - -
-
-
- - Github
-
- - Github
-
-
-
-
-
- - -
-

John Doe

- - -
-
-
- - Github
-
- - Github
-
-
-
-
+ <% if !UsersChapter.find_by(chapter_id: @chapter, leader: true).nil? %> + <% UsersChapter.where(chapter_id: @chapter, leader: true).each do |chapter_user| %> + <%= render 'chapter_leader_card', chapter: @chapter, user: chapter_user.user %> + <% end %> + <% else %> +

No Leaders yet

+ <% end %>
-
-

Question about event?

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor - incididunt ut labore et dolore magna aliqua.

-
-

Event Location

+

Chapter Location

- + +
+ +
+
-

iHub, Nairobi, Kenya

-
-

5.00 PM - 8.00 PM (EAT)

-

June 22, 2020

-
+

<%= @chapter.location %>

@@ -145,81 +91,17 @@ -
-
-
-
- -
-
-

Other events you may like

-
+ <%= link_to "https://www.facebook.com/sharer/sharer.php?u=#{request.original_url}" do %> + + <% end %> -
-
-
-
-

Kenya - Nairobi

-
-
- + <%= link_to "https://twitter.com/intent/tweet" do %> + + <% end %> -
-

Vim and Ruby on Rails

-
-

5.00 PM - 8.00 PM (EAT)

-

June 22, 2020

-
-
-
-
-
-
-
- -
-
-
-

Kenya - Mombasa

-
-
- - -
-

How to Ruby

-
-

5.00 PM - 8.00 PM (EAT)

-

June 22, 2020

-
-
-
-
-
-
-
- -
-
-
-

Kenya - Kisumu

-
-
- - -
-

Programming

-
-

5.00 PM - 8.00 PM (EAT)

-

June 22, 2020

-
-
-
+ <%= link_to "https://www.linkedin.com/sharing/share-offsite/?url=#{request.original_url}" do %> + + <% end %>
From a771a77e7fec8d6e8a335cf89d7e73e317cdf24b Mon Sep 17 00:00:00 2001 From: Bernard Banta Date: Wed, 14 Jun 2023 04:58:27 +0300 Subject: [PATCH 29/29] Add a slug field under fixtures --- test/fixtures/chapters.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fixtures/chapters.yml b/test/fixtures/chapters.yml index b7344642..ac296d0f 100644 --- a/test/fixtures/chapters.yml +++ b/test/fixtures/chapters.yml @@ -4,8 +4,10 @@ one: name: MyString location: MyString description: MyText + slug: MyText two: name: MyString location: MyString description: MyText + slug: MyText2