session_gem 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: edc87181c16caa5ab403c0531a01961187cecdb188539fb9aaf810b675146e4f
4
+ data.tar.gz: 910690b2c7764c9affbc602b8ac29f95bb0fd7336fb61a1ab043bd3d7cfb5a4f
5
+ SHA512:
6
+ metadata.gz: efee822f99af276e7d45e02d7af6fa98a9f0ce353e37d220c867899881369e170e850749d048127932ba611bf9ebcd92094afb20230e590801e5352bb6180683
7
+ data.tar.gz: 2383e05a3244c3323d7f70ac81fd6df24d5ee72ef0bd400f1b5bb6cb49069bc761eb0ce0b120aa711c3bacdae23c99546cbeaaef425be21f594770ded151ff90
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 ShravanEssence
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # SessionGem
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "session_gem"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install session_gem
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ //= link_directory ../stylesheets/session_gem .css
2
+ //= require turbolinks
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module SessionGem
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,53 @@
1
+ module SessionGem
2
+ class SessionsController < ApplicationController
3
+ include ActiveStorage::SetCurrent
4
+ def index
5
+ @sessions = Session.all
6
+ end
7
+
8
+ def show
9
+ @session = Session.find(params[:id])
10
+ end
11
+
12
+ def new
13
+ @session = Session.new
14
+ end
15
+
16
+ def create
17
+ @session = Session.new(session_params)
18
+ if @session.save
19
+ redirect_to @session
20
+ else
21
+ render :new, status: :unprocessable_entity
22
+ end
23
+ end
24
+
25
+ def edit
26
+ @session = Session.find(params[:id])
27
+ end
28
+
29
+ def update
30
+ @session = Session.find(params[:id])
31
+ if @session.update(session_params)
32
+ redirect_to @session
33
+ else
34
+ render :edit, status: :unprocessable_entity
35
+ end
36
+ end
37
+
38
+ def destroy
39
+ @session = Session.find(params[:id])
40
+ @session.destroy
41
+ redirect_to root_path
42
+ end
43
+
44
+ private
45
+ def session_params
46
+ params.require(:session).permit(:topic,:description,:user_id, :attachment)
47
+ end
48
+
49
+ def current_user
50
+ true
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,4 @@
1
+ module SessionGem
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SessionGem
2
+ module SessionsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SessionGem
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module SessionGem
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Ability
4
+ include CanCan::Ability
5
+
6
+ def initialize(user)
7
+
8
+ user ||= User.new # guest user (not logged in)
9
+
10
+ can :manage, :all
11
+ #if user.admin?
12
+ #can :manage, :all
13
+ #else
14
+ # can :read, :all
15
+ # can :update, :all
16
+ # can :delete, :all
17
+ #end
18
+ # Define abilities for the user here. For example:
19
+ #
20
+ # return unless user.present?
21
+ # can :read, :all
22
+ # return unless user.admin?
23
+ # can :manage, :all
24
+ #
25
+ # The first argument to `can` is the action you are giving the user
26
+ # permission to do.
27
+ # If you pass :manage it will apply to every action. Other common actions
28
+ # here are :read, :create, :update and :destroy.
29
+ #
30
+ # The second argument is the resource the user can perform the action on.
31
+ # If you pass :all it will apply to every resource. Otherwise pass a Ruby
32
+ # class of the resource.
33
+ #
34
+ # The third argument is an optional hash of conditions to further filter the
35
+ # objects.
36
+ # For example, here the user can only update published articles.
37
+ #
38
+ # can :update, Article, published: true
39
+ #
40
+ # See the wiki for details:
41
+ # https://github.com/CanCanCommunity/cancancan/blob/develop/docs/define_check_abilities.md
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module SessionGem
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module SessionGem
2
+ class Session < ApplicationRecord
3
+ has_one_attached :attachment
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module SessionGem
2
+ module SessionGem
3
+ def self.table_name_prefix
4
+ "session_gem_session_gem_"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Session gem</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "session_gem/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title></title>
7
+ </head>
8
+ <body style="background: white;">
9
+ <h1>New Session...</h1>
10
+ <%= form_with(model: session, local: true, html: { multipart: true}) do |form| %>
11
+ <div>
12
+ <%= form.label :topic %><br>
13
+ <%= form.text_field :topic %>
14
+ <% session.errors.full_messages_for(:topic).each do |message| %>
15
+ <div><%= message %></div>
16
+ <% end %>
17
+ </div>
18
+
19
+ <div>
20
+ <%= form.label :description %><br>
21
+ <%= form.text_area :description %>
22
+ <% session.errors.full_messages_for(:description).each do |message| %>
23
+ <div><%= message %></div>
24
+ <% end %>
25
+ </div>
26
+
27
+ <div>
28
+ <%= form.label :attachment %><br>
29
+ <%= form.file_field :attachment%>
30
+ </div>
31
+
32
+ <div>
33
+ <%= form.label :user_id %><br>
34
+ <%= form.text_field :user_id %>
35
+ <%#= form.select(:user_id, options_from_collection_for_select(User.all, "id","name")) %>
36
+ </div>
37
+
38
+ <div>
39
+ <%= form.submit %>
40
+ </div>
41
+ <% end %>
42
+ </body>
43
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title></title>
7
+ </head>
8
+ <body style="background: white;">
9
+ <%= render "form", session: @session %>
10
+ <div class="back">
11
+ <%= link_to "Back", root_path %>
12
+ </div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,15 @@
1
+ <h1>Sessions</h1>
2
+
3
+ <% @sessions.each do |session| %>
4
+ <h2><%= session.topic %></h2>
5
+ <p><%= session.description %></p>
6
+ <p><%= session.user_id %></p>
7
+ <% if can? :read, session %>
8
+ <%= link_to "Show Session Details", session, class: "btn btn-primary" %>
9
+ <% end %>
10
+ <% end %>
11
+ <% if can? :read, session %>
12
+ <%= link_to "New Session", new_session_path, class: "btn btn-primary" %>
13
+ <% end %>
14
+
15
+
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title></title>
7
+ </head>
8
+ <body style="background: white;">
9
+ <%= render "form", session: @session %>
10
+ <div class="back">
11
+ <%= link_to "Back", root_path %>
12
+ </div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title></title>
7
+ </head>
8
+ <body style="background: white;">
9
+ <%= link_to "Home", root_path %>
10
+
11
+ <h2><%= @session.topic %></h2>
12
+ <p><%= @session.description %></p>
13
+ <p><%= @session.user_id %></p>
14
+
15
+ <% if @session.attachment.attached? %>
16
+ <%= image_tag(@session.attachment.url, size: "200" ) %>
17
+ <% else %>
18
+ <p> image not showing</p>
19
+ <% end %>
20
+
21
+ <p><%= @session.attachment %></p>
22
+
23
+
24
+ <% if can? :update, @session %>
25
+ <%= link_to "Edit", edit_session_path(@session) %>
26
+ <% end %>
27
+
28
+ <% if can? :delete, @session %>
29
+ <%= form_with(model: @session, url: session_path(@session), method: :delete, data: { confirm: 'Are you sure?' }) do |form| %>
30
+ <%= form.submit 'Delete' %>
31
+ <% end %>
32
+ <% end %>
33
+
34
+
35
+
36
+ </body>
37
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ SessionGem::Engine.routes.draw do
2
+ root "sessions#index"
3
+ resources :sessions
4
+ end
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket-<%= Rails.env %>
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket-<%= Rails.env %>
23
+
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name-<%= Rails.env %>
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,11 @@
1
+ class CreateSessionGemSessions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :session_gem_sessions do |t|
4
+ t.string :topic
5
+ t.string :description
6
+ t.integer :user_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module SessionGem
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace SessionGem
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module SessionGem
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "session_gem/version"
2
+ require "session_gem/engine"
3
+
4
+ module SessionGem
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :session_gem do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: session_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - ShravanEssence
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.4.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.4.3
33
+ description: SessionGem for knowledge sessions.
34
+ email:
35
+ - shravankumar.essence@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - MIT-LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - app/assets/config/session_gem_manifest.js
44
+ - app/assets/stylesheets/session_gem/application.css
45
+ - app/controllers/session_gem/application_controller.rb
46
+ - app/controllers/session_gem/sessions_controller.rb
47
+ - app/helpers/session_gem/application_helper.rb
48
+ - app/helpers/session_gem/sessions_helper.rb
49
+ - app/jobs/session_gem/application_job.rb
50
+ - app/mailers/session_gem/application_mailer.rb
51
+ - app/models/ability.rb
52
+ - app/models/session_gem/application_record.rb
53
+ - app/models/session_gem/session.rb
54
+ - app/models/session_gem/session_gem.rb
55
+ - app/views/layouts/session_gem/application.html.erb
56
+ - app/views/session_gem/sessions/_form.html.erb
57
+ - app/views/session_gem/sessions/edit.html.erb
58
+ - app/views/session_gem/sessions/index.html.erb
59
+ - app/views/session_gem/sessions/new.html.erb
60
+ - app/views/session_gem/sessions/show.html.erb
61
+ - config/routes.rb
62
+ - config/storage.yml
63
+ - db/migrate/20230524061415_create_session_gem_sessions.rb
64
+ - lib/session_gem.rb
65
+ - lib/session_gem/engine.rb
66
+ - lib/session_gem/version.rb
67
+ - lib/tasks/session_gem_tasks.rake
68
+ homepage: https://github.com/shravan-essence/session_gem
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.2.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: SessionGem is used for knowledge sessions.
91
+ test_files: []