Skip to content

Commit

Permalink
Merge pull request #32 from leouofa/perspective-controller
Browse files Browse the repository at this point in the history
Setting up perspectives
  • Loading branch information
leouofa authored Sep 22, 2024
2 parents eb10523 + 8b6057e commit ca6f5dc
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def component_class
end

def component_params
params.require(@computer_name.to_sym).permit(:title, :writing_style_id)
params.require(@computer_name.to_sym).permit(:title, :writing_style_id, :perspective_id)
end
end
15 changes: 15 additions & 0 deletions app/controllers/perspectives_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class PerspectivesController < MetaController
def index
scope = set_scope
where = set_where
@component_list = @component_klass.send('where', where).send(scope).order(created_at: :asc).page params[:page]
end

def component_name
'Perspectives'
end

def component_class
'Perspective'.constantize
end
end
2 changes: 2 additions & 0 deletions app/helpers/perspectives_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PerspectivesHelper
end
4 changes: 4 additions & 0 deletions app/views/books/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
= form.label :writing_style_id, "Writing Style"
= form.collection_select :writing_style_id, WritingStyle.all, :id, :name, { prompt: "Select a Writing Style" }, class: "ui dropdown"

= r ux.component_field
= form.label :perspective_id, "Perspective"
= form.collection_select :perspective_id, Perspective.all, :id, :name, { prompt: "Select a Perspective" }, class: "ui dropdown"

=r ux.component_submit_field
= form.submit class: 'btn-primary'
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ html lang="en"
=r ux.icon 'vest patches'
| Writing Styles

= link_to perspectives_path, class: "item #{menu_active?(perspectives_path)}"
=r ux.icon 'user tie'
| Perspectives


/
/
Expand Down
39 changes: 39 additions & 0 deletions app/views/perspectives/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=r ux.container
=r ux.row
=r ux.column width: 16
= turbo_frame_tag 'crud_frame'
=r ux.component_container
=r ux.component_header
=@component_name.pluralize
=r ux.component_divider

=r ux.div 'text-center'
= paginate @component_list

=r ux.table class: 'relaxed celled striped structured'
=r ux.thead
=r ux.tr
=r ux.th text: 'Perspective Name'
=r ux.th text: 'Description'
- @component_list.each do |component|
=r ux.tr
=r ux.td '!pr-4 !border-b-4 border-solid'
=r ux.h4 text: component.name
br
- YAML.load(component.pronouns).each do |pronoun|
=r ux.label text: pronoun.capitalize, class: '!mb-3 !bg-violet-500 !text-white !font-normal'
=r ux.td '!border-b-4 border-solid'
=r ux.segment '!mt-3 !bg-blue-100'
=r ux.h4 text: "Explanation"
= component.narrator

=r ux.segment '!mt-3 !bg-green-100'
=r ux.h4 text: "Effect"
= component.effect

=r ux.segment '!mt-3 !mb-2 !bg-yellow-100'
=r ux.h4 text: "Example"
= component.example

=r ux.div 'text-center'
= paginate @component_list
12 changes: 0 additions & 12 deletions blueprints/perspectives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ perspectives:
effect: "Captures the inner workings of the mind in real time, often appearing fragmented or non-linear."
example: "Rain. Cold. Why didn’t I bring the umbrella? Can’t stand this anymore—what did she say? What was I thinking?"

- name: Second-Person Plural
narrator: "The narrator addresses a group of people, making the audience part of a collective 'you'."
pronouns: ["You", "your", "y'all"]
effect: "Creates a shared or communal experience, often evoking a sense of unity or collective responsibility."
example: "You all walked down the road, together but alone in your thoughts, yet bound by the same mission."

- name: Unreliable Narrator
narrator: "Can be either first-person or third-person, but the narrator cannot be fully trusted to present the truth."
pronouns: ["I", "he", "she", "they"]
effect: "Creates ambiguity or tension, as the reader must decide how much of the story to believe."
example: "I couldn’t have done it. I wasn’t even there... or maybe I was. I can’t remember."

- name: Epistolary (Letters or Documents)
narrator: "The story is told through letters, diary entries, or other forms of written communication, which can be written by multiple characters."
pronouns: ["I", "he", "she", "they"]
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
end

resources :books do

end

resources :perspectives

resources :unauthorized, only: %i[index]
resources :settings, only: [:index, :edit]
resource :settings, only: [:update]
Expand Down

0 comments on commit ca6f5dc

Please sign in to comment.