Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
InterceptApi, ProjectsHelper, SetHousekeeping, Tracking::UserTime, Whitelist, Workbench::SessionsHelper
Defined in:
app/controllers/application_controller.rb

Overview

TODO: likely required here because of routes, but it shouldn't be!! fixing routes to be static via include shoudl solve this require_dependency 'lib/application_enumeration.rb'

Direct Known Subclasses

AdministrationController, AlternateValuesController, AnnotationsController, Api::V1::TaxonNamesController, ApiController, AssertedDistributionsController, AuthorsController, BiocurationClassificationsController, BiologicalAssociationsController, BiologicalAssociationsGraphsController, BiologicalRelationshipsController, CharacterStatesController, CitationTopicsController, CitationsController, CollectingEventsController, CollectionObjectObservationsController, CollectionObjectsController, CollectionProfilesController, CombinationsController, CommonNamesController, ConfidenceLevelsController, ConfidencesController, ContainerItemsController, ContainersController, ContentsController, ControlledVocabularyTermsController, CrashTestController, DashboardController, DataAttributesController, DepictionsController, DescriptorsController, DocumentationController, DocumentsController, ExtractsController, GeneAttributesController, GeographicAreaTypesController, GeographicAreasController, GeographicAreasGeographicItemsController, GeographicItemsController, Georeferences::GeoLocatesController, Georeferences::GoogleMapsController, GeoreferencesController, GraphController, HubController, IdentifiersController, ImagesController, KeywordsController, LanguagesController, LoanItemsController, LoansController, NamespacesController, NotesController, ObservationMatricesController, ObservationMatrixColumnItemsController, ObservationMatrixColumnsController, ObservationMatrixRowItemsController, ObservationMatrixRowsController, ObservationsController, OriginRelationshipsController, OtuPageLayoutSectionsController, OtuPageLayoutsController, OtusController, PeopleController, PinboardItemsController, PingController, PredicatesController, PreparationTypesController, ProjectMembersController, ProjectSourcesController, ProjectsController, ProtocolRelationshipsController, ProtocolsController, PublicContentsController, RangedLotCategoriesController, RepositoriesController, SequenceRelationshipsController, SequencesController, SerialChronologiesController, SerialsController, SessionsController, SoftValidationsController, SourcesController, TaggedSectionKeywordsController, TagsController, Tasks::Accessions::Breakdown::BufferedDataController, Tasks::Accessions::Breakdown::SqedDepictionController, Tasks::Accessions::ComprehensiveController, Tasks::Accessions::Quick::SimpleController, Tasks::Accessions::Quick::VerbatimMaterialController, Tasks::Accessions::Report::DwcController, Tasks::Accessions::Verify::MaterialController, Tasks::Bibliography::VerbatimReferenceController, Tasks::Citations::OtusController, Tasks::CollectingEvents::Parse::Stepwise::DatesController, Tasks::CollectingEvents::Parse::Stepwise::LatLongController, Tasks::CollectionObjects::BrowseController, Tasks::CollectionObjects::FilterController, Tasks::Content::EditorController, Tasks::Content::PreviewController, Tasks::ControlledVocabularies::BiocurationController, Tasks::Descriptors::NewDescriptorController, Tasks::Gis::AssertedDistributionController, Tasks::Gis::DrawableMapController, Tasks::Gis::GeographicAreaLookupController, Tasks::Gis::LocalityController, Tasks::Gis::MatchGeoreferenceController, Tasks::Gis::OtuDistributionDataController, Tasks::Import::Dwca::PsuImportController, Tasks::Loans::EditLoanController, Tasks::Loans::OverdueController, Tasks::Nomenclature::BrowseController, Tasks::Nomenclature::BySourceController, Tasks::Nomenclature::Catalog::BasisController, Tasks::Nomenclature::NewCombinationController, Tasks::Nomenclature::NewTaxonNameController, Tasks::ObservationMatrices::NewMatrixController, Tasks::ObservationMatrices::RowCoderController, Tasks::Otus::BrowseController, Tasks::Otus::FilterController, Tasks::People::AuthorController, Tasks::Serials::SimilarController, Tasks::Sources::BrowseController, Tasks::Sources::IndividualBibtexSourceController, Tasks::TypeMaterial::EditTypeMaterialController, Tasks::Uniquify::PeopleController, Tasks::Usage::UserActivityController, TaxonDeterminationsController, TaxonNameClassificationsController, TaxonNameRelationshipsController, TaxonNamesController, TopicsController, TypeMaterialsController, UserPreferencesController, UsersController

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Attribute Details

- (Object) is_data_controller=(value) (writeonly)

Sets the attribute is_data_controller

Parameters:

  • value

    the value to set the attribute is_data_controller to.



23
24
25
# File 'app/controllers/application_controller.rb', line 23

def is_data_controller=(value)
  @is_data_controller = value
end

- (Object) is_task_controller=(value) (writeonly)

Sets the attribute is_task_controller

Parameters:

  • value

    the value to set the attribute is_task_controller to.



23
24
25
# File 'app/controllers/application_controller.rb', line 23

def is_task_controller=(value)
  @is_task_controller = value
end

- (Object) meta_data



57
58
59
60
61
62
# File 'app/controllers/application_controller.rb', line 57

def 
  @meta_data ||= {
    description: @meta_description,
    keywords: @meta_keywords
  }.delete_if { |_k, v| v.nil? }
end

- (Object) meta_description

Returns the value of attribute meta_description



27
28
29
# File 'app/controllers/application_controller.rb', line 27

def meta_description
  @meta_description
end

- (Object) meta_keywords

Returns the value of attribute meta_keywords



27
28
29
# File 'app/controllers/application_controller.rb', line 27

def meta_keywords
  @meta_keywords
end

- (Object) meta_title



53
54
55
# File 'app/controllers/application_controller.rb', line 53

def meta_title
  @meta_title ||= [@meta_title.presence || @page_title.presence, site_name].compact.join(' | ')
end

- (Object) page_title

Returns the value of attribute page_title



27
28
29
# File 'app/controllers/application_controller.rb', line 27

def page_title
  @page_title
end

- (Object) site_name



64
65
66
# File 'app/controllers/application_controller.rb', line 64

def site_name
  @site_name ||= 'TaxonWorks'
end

Instance Method Details



68
69
70
71
# File 'app/controllers/application_controller.rb', line 68

def digest_cookie(file, key)
  sha256 = Digest::SHA256.file(file)
  cookies[key] = sha256.hexdigest
end

Returns:

  • (Boolean)


73
74
75
76
# File 'app/controllers/application_controller.rb', line 73

def digested_cookie_exists?(file, key)
  sha256 = Digest::SHA256.file(file)
  cookies[key] == sha256.hexdigest
end


87
88
89
# File 'app/controllers/application_controller.rb', line 87

def disable_turbolinks
  @no_turbolinks = true
end

- (Object) invalid_object(object) (private)



95
96
97
# File 'app/controllers/application_controller.rb', line 95

def invalid_object(object)
  !(!object.try(:project_id) || project_matches(object))
end

- (Boolean) is_data_controller?

Returns true if the controller is that of data class. See controllers/concerns/data_controller_configuration/ concern. Data controllers can not be task controllers.

Returns:

  • (Boolean)


43
44
45
# File 'app/controllers/application_controller.rb', line 43

def is_data_controller?
  @is_data_controller
end

- (Boolean) is_task_controller?

Returns true if the controller is a task controller. See controllers/concerns/task_controller_configuration/ concern. Task controllers can not be data controllers.

Returns:

  • (Boolean)


49
50
51
# File 'app/controllers/application_controller.rb', line 49

def is_task_controller?
  @is_task_controller
end

- (Object) log_user_recent_route

TODO: Make RecenRoutes modules that handles exceptions, only etc.



37
38
39
# File 'app/controllers/application_controller.rb', line 37

def log_user_recent_route
  # sessions_current_user.add_recently_visited_to_footprint(request.fullpath, @recent_object) if sessions_current_user
end

- (Object) project_matches(object) (private)



99
100
101
# File 'app/controllers/application_controller.rb', line 99

def project_matches(object)
  object.try(:project_id) == sessions_current_project_id
end

- (Object) record_not_found (private)



80
81
82
83
84
85
# File 'app/controllers/application_controller.rb', line 80

def record_not_found
  respond_to do |format|
    format.html { render plain: '404 Not Found', status: 404 }
    format.json { render json: {success: false}, status: 404 }
  end
end

- (Object) set_project_from_params (private)



91
92
93
# File 'app/controllers/application_controller.rb', line 91

def set_project_from_params
  self.sessions_current_project_id = params[:project_id]
end