Compare commits

..

2 Commits

Author SHA1 Message Date
Brenda Wallace
f5377662cf Merge remote-tracking branch 'upstream/dev' into feature/dotenv 2020-08-01 20:17:33 +12:00
Brenda Wallace
efc2e70bf8 Remove figaro gem and use rails-dotenv 2020-08-01 20:16:33 +12:00
254 changed files with 3631 additions and 4110 deletions

View File

@@ -1,37 +1,28 @@
plugins:
brakeman:
enabled: false # codeclimate's brakeman is stuck in rails 5 rules
bundler-audit:
engines:
rubocop:
enabled: true
channel: "rubocop-0-88"
scss-lint:
enabled: true
shellcheck:
enabled: true
eslint:
enabled: true
coffeelint:
enabled: true
brakeman:
enabled: true
bundler-audit:
enabled: true
duplication:
enabled: true
config:
languages:
- ruby
- javascript
editorconfig:
enabled: true
eslint:
enabled: true
fixme:
enabled: true
haml-lint:
enabled: true
nodesecurity:
enabled: true
rubocop:
enabled: true
channel: "rubocop-1-11"
scss-lint:
enabled: true
shellcheck:
enabled: true
ratings:
paths:
- "**.rb"
- "**.ru"
- "**.js"
- "**.coffee"
- "**.scss"

View File

@@ -1,59 +0,0 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
time: "07:00"
open-pull-requests-limit: 20
versioning-strategy: lockfile-only
ignore:
- dependency-name: active_median
versions:
- "< 0.2.2, >= 0.2.1.a"
- dependency-name: rubocop
versions:
- "< 0.63, >= 0.62.a"
- dependency-name: rubocop
versions:
- "< 0.64, >= 0.63.a"
- dependency-name: sidekiq
versions:
- 5.2.4
- dependency-name: oj
versions:
- 3.11.4
- dependency-name: listen
versions:
- 3.5.0
- dependency-name: rspec-rails
versions:
- 4.1.0
- 5.0.0
- dependency-name: searchkick
versions:
- 4.4.3
- dependency-name: rswag-api
versions:
- 2.3.3
- dependency-name: rswag-specs
versions:
- 2.3.3
- dependency-name: rswag-ui
versions:
- 2.3.3
- dependency-name: timecop
versions:
- 0.9.3
- dependency-name: puma
versions:
- 5.2.0
- dependency-name: capybara
versions:
- 3.35.1
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "07:00"
open-pull-requests-limit: 10

View File

@@ -1,40 +0,0 @@
# This workflow integrates Brakeman with GitHub's Code Scanning feature
# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications
name: Brakeman Scan
# This section configures the trigger for the workflow. Feel free to customize depending on your convention
on:
pull_request:
branches: [ dev ]
jobs:
brakeman-scan:
name: Brakeman Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
# Customize the ruby version depending on your needs
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Setup Brakeman
env:
BRAKEMAN_VERSION: '5.1.1' # SARIF support is provided in Brakeman version 4.10+
run: |
gem install brakeman --version $BRAKEMAN_VERSION
# Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis
- name: Scan
continue-on-error: true
run: |
brakeman -f sarif -o output.sarif.json .
# Upload the SARIF file generated in the previous step
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: output.sarif.json

View File

@@ -1,122 +0,0 @@
name: CI
on: [pull_request]
jobs:
contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install gem bundle
run: |
gem install bundler
bundle install
- name: Check contributors
run: |
bundle exec script/check_contributors_md.rb
rspec:
runs-on: ubuntu-latest
services:
db:
image: postgres
env:
##
# The Postgres service fails its docker health check unless you
# specify these environment variables
#
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: growstuff_test
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
APP_DOMAIN_NAME: localhost:3000
APP_PROTOCOL: http
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test
DEVISE_SECRET_KEY: secret
ELASTIC_SEARCH_VERSION: "7.5.1-amd64"
GROWSTUFF_EMAIL: "noreply@test.growstuff.org"
GROWSTUFF_FLICKR_KEY: secretkey"
GROWSTUFF_FLICKR_SECRET: secretsecret
GROWSTUFF_SITE_NAME: "Growstuff (travis)"
RAILS_ENV: test
RAILS_SECRET_TOKEN: supersecret
steps:
- name: Checkout this repo
uses: actions/checkout@v3
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Start Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.5.1
##
# Cache Yarn modules
#
# See https://github.com/actions/cache/blob/master/examples.md#node---yarn for details
#
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup yarn cache
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install required OS packages
run: |
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: '12'
- name: Install Ruby (version given by .ruby-version) and Bundler
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install required JS packages
run: yarn install
- name: install chrome
run: sudo apt-get install google-chrome-stable
- name: Prepare database for testing
run: bundle exec rails db:prepare
- name: precompile assets
run: bundle exec rails assets:precompile
- name: index into elastic search
run: bundle exec rails search:reindex
- name: Run rspec (report results to Percy.io and CodeClimate)
run: bundle exec rspec spec -fd
- name: Report to code climate
run: |
gem install codeclimate-test-reporter
codeclimate-test-reporter

1
.gitignore vendored
View File

@@ -1,6 +1,5 @@
.byebug_history
.bundle
.env
# Folders to ignore
/log

View File

@@ -1,13 +1,10 @@
inherit_from: .rubocop_todo.yml
require:
- rubocop-rails
- rubocop-rspec
require: rubocop-rails
AllCops:
NewCops: enable
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
TargetRailsVersion: 6.0
TargetRailsVersion: 5.2
Rails:
Enabled: true
@@ -18,11 +15,6 @@ Naming/FileName:
- 'Gemfile'
- 'Gemfile.lock'
RSpec/DescribeClass:
Exclude:
- 'spec/views/**/*.rb'
- 'spec/features/**/*.rb'
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

View File

@@ -1,384 +1,21 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-11-07 13:39:24 UTC using RuboCop version 1.38.0.
# `rubocop --auto-gen-config --no-offense-counts`
# on 2019-12-16 21:01:58 +1300 using RuboCop version 0.77.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Lint/AmbiguousOperator:
Exclude:
- 'db/migrate/20171129041341_create_photographings.rb'
- 'db/migrate/20190130090437_add_crop_to_photographings.rb'
- 'spec/controllers/crops_controller_spec.rb'
# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: space, no_space
Layout/LineContinuationSpacing:
Exclude:
- 'app/mailers/notifier_mailer.rb'
- 'app/models/seed.rb'
- 'lib/tasks/growstuff.rake'
- 'spec/features/rss/plantings_spec.rb'
- 'spec/features/rss/posts_spec.rb'
- 'spec/features/rss/seeds_spec.rb'
- 'spec/models/seed_spec.rb'
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'app/mailers/notifier_mailer.rb'
- 'app/models/seed.rb'
- 'lib/tasks/growstuff.rake'
- 'spec/features/rss/plantings_spec.rb'
- 'spec/features/rss/posts_spec.rb'
- 'spec/features/rss/seeds_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 304
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Lint/AmbiguousOperatorPrecedence:
Exclude:
- 'db/seeds.rb'
- 'spec/helpers/gardens_helper_spec.rb'
- 'spec/helpers/seeds_helper_spec.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: RequireParenthesesForMethodChains.
Lint/AmbiguousRange:
Exclude:
- 'app/models/concerns/search_harvests.rb'
- 'app/models/concerns/search_plantings.rb'
# Offense count: 2
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
- 'app/models/harvest.rb'
- 'lib/actions/oauth_signup_action.rb'
# Offense count: 8
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'db/migrate/20171022032108_all_the_predictions.rb'
- 'spec/controllers/home_controller_spec.rb'
- 'spec/controllers/likes_controller_spec.rb'
- 'spec/controllers/plant_parts_controller_spec.rb'
- 'spec/factories/crop_companions.rb'
- 'spec/features/crops/crop_detail_page_spec.rb'
- 'spec/requests/authentications_spec.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/RedundantDirGlobSort:
Exclude:
- 'spec/rails_helper.rb'
# Offense count: 1
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Exclude:
- 'lib/tasks/testing.rake'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, consistent
Lint/SymbolConversion:
Exclude:
- 'app/controllers/likes_controller.rb'
# Offense count: 8
Lint/UselessAssignment:
Exclude:
- 'config.rb'
- 'config/compass.rb'
- 'lib/actions/oauth_signup_action.rb'
# Offense count: 44
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 151
# Offense count: 10
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 61
# Offense count: 6
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 171
# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 32
# Offense count: 59
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
Max: 59
# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 32
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: lowercase, uppercase
Naming/HeredocDelimiterCase:
Exclude:
- 'config/environments/production.rb'
# Offense count: 3
RSpec/AnyInstance:
Exclude:
- 'spec/controllers/harvests_controller_spec.rb'
- 'spec/controllers/photos_controller_spec.rb'
# Offense count: 15
RSpec/Capybara/SpecificMatcher:
Exclude:
- 'spec/features/crops/browse_crops_spec.rb'
- 'spec/features/footer_spec.rb'
- 'spec/features/gardens/adding_gardens_spec.rb'
- 'spec/features/harvests/harvesting_a_crop_spec.rb'
- 'spec/features/plantings/planting_a_crop_spec.rb'
- 'spec/features/seeds/adding_seeds_spec.rb'
# Offense count: 1
RSpec/Capybara/VisibilityMatcher:
Exclude:
- 'spec/features/shared_examples/crop_suggest.rb'
# Offense count: 292
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false
# Offense count: 36
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/models/like_spec.rb'
- 'spec/models/member_spec.rb'
- 'spec/services/timeline_service_spec.rb'
# Offense count: 13
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/EmptyExampleGroup:
Exclude:
- 'spec/controllers/authentications_controller_spec.rb'
- 'spec/controllers/forums_controller_spec.rb'
- 'spec/controllers/home_controller_spec.rb'
- 'spec/controllers/likes_controller_spec.rb'
- 'spec/controllers/plant_parts_controller_spec.rb'
- 'spec/controllers/seeds_controller_spec.rb'
- 'spec/features/crops/crop_detail_page_spec.rb'
- 'spec/features/plantings/planting_a_crop_spec.rb'
- 'spec/requests/authentications_spec.rb'
- 'spec/views/home/index_spec.rb'
- 'spec/views/photos/edit.html.haml_spec.rb'
- 'spec/views/posts/_single.html.haml_spec.rb'
# Offense count: 136
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 25
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/ExcessiveDocstringSpacing:
Exclude:
- 'spec/controllers/crops_controller_spec.rb'
- 'spec/features/crops/crop_photos_spec.rb'
# Offense count: 30
RSpec/ExpectInHook:
Exclude:
- 'spec/controllers/garden_types_controller_spec.rb'
- 'spec/controllers/gardens_controller_spec.rb'
- 'spec/features/admin/forums_spec.rb'
- 'spec/features/crops/crop_photos_spec.rb'
- 'spec/features/members/list_spec.rb'
- 'spec/features/plantings/planting_a_crop_spec.rb'
- 'spec/features/shared_examples/append_date.rb'
# Offense count: 1135
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/FactoryBot/SyntaxMethods:
Enabled: false
# Offense count: 3
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/controllers/member_controller_spec.rb'
- 'spec/features/seeds/seed_photos.rb'
- 'spec/models/garden_type.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Exclude:
- 'spec/requests/api/v1/plantings_request_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/HooksBeforeExamples:
Exclude:
- 'spec/features/crops/creating_a_crop_spec.rb'
# Offense count: 710
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Enabled: false
# Offense count: 40
RSpec/LetSetup:
Enabled: false
# Offense count: 2
RSpec/MessageChain:
Exclude:
- 'spec/models/member_spec.rb'
# Offense count: 23
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive
# Offense count: 1
RSpec/MultipleDescribes:
Exclude:
- 'spec/features/crops/crop_wranglers_spec.rb'
# Offense count: 149
RSpec/MultipleExpectations:
Max: 19
# Offense count: 137
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 14
# Offense count: 132
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Enabled: false
# Offense count: 111
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6
# Offense count: 407
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
Enabled: false
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/Rails/HaveHttpStatus:
Exclude:
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
- 'spec/controllers/harvests_controller_spec.rb'
- 'spec/requests/harvests_spec.rb'
# Offense count: 16
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences.
RSpec/Rails/InferredSpecType:
Enabled: false
# Offense count: 2
RSpec/RepeatedDescription:
Exclude:
- 'spec/models/like_spec.rb'
# Offense count: 6
RSpec/RepeatedExample:
Exclude:
- 'spec/controllers/photos_controller_spec.rb'
- 'spec/features/members/following_spec.rb'
- 'spec/models/like_spec.rb'
# Offense count: 4
RSpec/RepeatedExampleGroupBody:
Exclude:
- 'spec/controllers/crops_controller_spec.rb'
# Offense count: 6
RSpec/ScatteredSetup:
Exclude:
- 'spec/features/percy/percy_spec.rb'
- 'spec/features/plantings/prediction_spec.rb'
# Offense count: 3
RSpec/StubbedMock:
Exclude:
- 'spec/controllers/garden_types_controller_spec.rb'
- 'spec/controllers/gardens_controller_spec.rb'
- 'spec/models/member_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: constant, string
RSpec/VerifiedDoubleReference:
Exclude:
- 'spec/models/member_spec.rb'
# Offense count: 3
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/controllers/garden_types_controller_spec.rb'
- 'spec/controllers/gardens_controller_spec.rb'
- 'spec/views/devise/shared/_links_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ActionControllerFlashBeforeRender:
Exclude:
- 'app/controllers/authentications_controller.rb'
# Offense count: 26
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql, postgresql
# Include: db/migrate/*.rb
Rails/BulkChangeTable:
Enabled: false
# Offense count: 11
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Rails/CreateTableWithTimestamps:
@@ -393,14 +30,12 @@ Rails/CreateTableWithTimestamps:
- 'db/migrate/20161201154922_add_photos_seeds_table.rb'
- 'db/migrate/20171022032108_all_the_predictions.rb'
# Offense count: 1
# Configuration parameters: EnforcedStyle, AllowToTime.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, flexible
Rails/Date:
Exclude:
- 'app/mailers/notifier_mailer.rb'
- 'app/mailers/notifier.rb'
# Offense count: 5
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
@@ -410,7 +45,6 @@ Rails/FilePath:
- 'config/environments/development.rb'
- 'db/seeds.rb'
# Offense count: 2
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
@@ -418,39 +52,23 @@ Rails/HasAndBelongsToMany:
- 'app/models/member.rb'
- 'app/models/role.rb'
# Offense count: 5
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/member.rb'
# Offense count: 1
# Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb
Rails/I18nLocaleAssignment:
# Include: app/models/**/*.rb
Rails/InverseOf:
Exclude:
- 'spec/features/locale_spec.rb'
- 'app/models/concerns/ownable.rb'
# Offense count: 33
Rails/I18nLocaleTexts:
Enabled: false
# Offense count: 2
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/data_controller.rb'
# Offense count: 2
Rails/OutputSafety:
Exclude:
- 'app/helpers/auto_suggest_helper.rb'
- 'app/helpers/gardens_helper.rb'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: **/Rakefile, **/*.rake
Rails/RakeEnvironment:
@@ -459,53 +77,27 @@ Rails/RakeEnvironment:
- 'lib/tasks/i18n.rake'
- 'lib/tasks/testing.rake'
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RedundantPresenceValidationOnBelongsTo:
Exclude:
- 'app/models/alternate_name.rb'
- 'app/models/like.rb'
- 'app/models/planting.rb'
- 'app/models/scientific_name.rb'
# Offense count: 9
# Configuration parameters: Include.
# Include: db/**/*.rb
# Include: db/migrate/*.rb
Rails/ReversibleMigration:
Exclude:
- 'db/migrate/20130326092227_change_planted_at_to_date.rb'
- 'db/migrate/20191119020643_upgrade_cms.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RootPathnameMethods:
# Configuration parameters: Blacklist, Whitelist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
Rails/SkipsModelValidations:
Exclude:
- 'app/controllers/crops_controller.rb'
- 'app/helpers/icons_helper.rb'
- 'db/migrate/20190317023129_finished_boolean.rb'
- 'db/seeds.rb'
- 'db/migrate/20190910022329_add_photo_source.rb'
# Offense count: 6
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
# Configuration parameters: AllowedChars.
Style/AsciiComments:
Exclude:
- 'app/models/follow.rb'
- 'app/models/garden.rb'
- 'app/models/like.rb'
- 'app/models/member.rb'
- 'app/models/plant_part.rb'
- 'app/models/role.rb'
- 'config/initializers/comfortable_mexican_sofa.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/WhereEquals:
Exclude:
- 'app/models/crop.rb'
- 'app/models/harvest.rb'
- 'app/models/planting.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
@@ -513,133 +105,23 @@ Style/ClassAndModuleChildren:
- 'lib/haml/filters/escaped_markdown.rb'
- 'lib/haml/filters/growstuff_markdown.rb'
# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CommentedKeyword:
Exclude:
- 'db/migrate/20191119030244_cms_tags.rb'
- 'spec/models/crop_spec.rb'
- 'spec/models/photo_spec.rb'
- 'spec/models/planting_spec.rb'
# Offense count: 42
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Enabled: false
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'config/initializers/new_framework_defaults_6_0.rb'
- 'db/migrate/20200801084007_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb'
- 'db/migrate/20200815012538_remove_median_function.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/production.rb'
- 'lib/tasks/openfarm.rake'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'bin/setup'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods.
# AllowedMethods: nonzero?
Style/IfWithBooleanLiteralBranches:
Exclude:
- 'app/controllers/gardens_controller.rb'
# Offense count: 2
Style/MixinUsage:
Exclude:
- 'bin/setup'
- 'bin/update'
- 'spec/rails_helper.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/NegatedIfElseCondition:
Exclude:
- 'app/helpers/crops_helper.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'app/helpers/harvests_helper.rb'
- 'app/helpers/plantings_helper.rb'
# Offense count: 6
Style/OpenStructUse:
Exclude:
- 'spec/helpers/event_helper_spec.rb'
# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/models/concerns/member_newsletter.rb'
# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
Style/QuotedSymbols:
Exclude:
- 'app/models/seed.rb'
- 'spec/controllers/crops_controller_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Methods.
Style/RedundantArgument:
Exclude:
- 'app/helpers/application_helper.rb'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeForConstants.
Style/RedundantFetchBlock:
Exclude:
- 'config/puma.rb'
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowModifier.
Style/SoleNestedConditional:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/messages_controller.rb'
- 'app/models/photo_association.rb'
# Offense count: 20
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'app/controllers/messages_controller.rb'
- 'app/helpers/buttons_helper.rb'
- 'config/initializers/rswag_api.rb'
- 'spec/helpers/gardens_helper_spec.rb'
- 'spec/helpers/seeds_helper_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments.
# AllowedMethods: define_method, mail, respond_to
Style/SymbolProc:
Exclude:
- 'app/controllers/crops_controller.rb'

View File

@@ -1 +1 @@
3.1.2
2.6.5

View File

@@ -1,18 +1,52 @@
sudo: required
language: ruby
dist: bionic
branches:
only:
- mainline
- dev
services:
- postgresql
- xvfb
cache:
bundler: true
yarn: true
directories:
- tmp/cache/assets/test/sprockets
addons:
postgresql: "9.4"
code_climate:
repo_token:
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
env:
matrix:
- ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
- STATIC_CHECKS=true
global:
- secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4="
- GROWSTUFF_EMAIL="noreply@test.growstuff.org"g
- GROWSTUFF_SITE_NAME="Growstuff (travis)"
- RAILS_SECRET_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
before_install:
- sudo apt clean
- sudo apt update
- sudo apt install dpkg
- ./script/install_elasticsearch.sh
- sudo apt install google-chrome-stable
- ./script/install_linters.sh
- ./script/check_elasticsearch.sh
script:
- >
if [ "${STATIC_CHECKS}" = "true" ]; then
./script/check_static.rb
else
bundle exec rails db:create db:migrate;
bundle exec rails assets:precompile;
bundle exec rails search:reindex;
bundle exec rspec spec;
# npx percy exec -- bundle exec rspec spec # <- run this to send screen shots to percy
fi;
after_script:
- >
if [ "${COVERAGE}" = "true" ]; then
gem install codeclimate-test-reporter
codeclimate-test-reporter
fi
before_deploy:
- bundle exec script/heroku_maintenance.rb on
deploy:
@@ -25,6 +59,7 @@ deploy:
dev: growstuff-staging
mainline: growstuff-prod
run:
- "rake db:migrate"
- "script/deploy-tasks.sh"
- restart
after_deploy:

View File

@@ -91,11 +91,9 @@ submit the change with your pull request.
- Taylor William / [bestest-mensch](https://github.com/bestest-mensch)
- André Aubin / [lambda2](https://github.com/lambda2)
- Martina Simicic / [simicic](https://github.com/simicic)
- Rowan Crawford / [wombleton](https://github.com/wombleton)
- Ítalo Pires / [italopires](https://github.com/italopires)
## Bots
### Security and Dependency Updates
- DeppBot / [deppbot](https://github.com/deppbot)
- `dependabot[bot]` [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)
- dependabot-preview[bot] [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)

30
Gemfile
View File

@@ -2,16 +2,15 @@
source 'https://rubygems.org'
# Match ruby version in .ruby-version
ruby File.read('.ruby-version')
ruby '2.6.5'
gem 'rails', '~> 7.0.4'
gem 'rails', '5.2.4.3'
# Keeping old sprockets
# https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050
gem "sprockets", "<4"
gem 'bundler', '>= 2.3.10'
gem 'bundler', '>=1.1.5'
gem 'coffee-rails'
gem 'haml'
@@ -24,7 +23,7 @@ gem 'rswag-api'
gem 'rswag-ui'
# CSS framework
gem "bootstrap", ">= 4.6.2"
gem "bootstrap", ">= 4.3.1"
gem 'material-sass', '4.1.1'
# Icons used by bootstrap/material-sass
@@ -39,7 +38,7 @@ gem 'oj' # Speeds up json
# planting and harvest predictions
# based on median values for the crop
gem 'active_median', '0.2.0'
gem 'active_median', '0.1.4' # needs postgresql update https://github.com/Growstuff/growstuff/issues/1757
gem 'active_record_union'
gem 'flickraw'
@@ -52,14 +51,14 @@ gem 'csv_shaper' # CSV export
gem 'gibbon', '~>1.2.0' # for Mailchimp newsletter subscriptions
# Maps
gem 'leaflet-rails', '>= 1.9.2'
gem 'leaflet-rails'
gem 'rails-assets-leaflet.markercluster', source: 'https://rails-assets.org'
gem 'pg'
gem 'pg', '< 1.0.0' # Upstream bug, see https://github.com/Growstuff/growstuff/pull/1539
gem 'ruby-units' # for unit conversion
gem 'unicorn' # http server
gem "comfortable_mexican_sofa", git: "https://github.com/restarone/comfortable-mexican-sofa.git"
gem "comfortable_mexican_sofa", "~> 2.0.0"
gem 'active_utils'
gem 'sidekiq'
@@ -90,10 +89,11 @@ gem 'geocoder'
gem 'bootstrap-datepicker-rails'
# DRY-er easier bootstrap 4 forms
gem "bootstrap_form", ">= 4.5.0"
gem "bootstrap_form", ">= 4.2.0"
# For connecting to other services (eg Twitter)
gem 'omniauth', '~> 1.3'
gem 'omniauth-facebook'
gem 'omniauth-flickr', '>= 0.0.15'
gem 'omniauth-twitter'
@@ -112,17 +112,17 @@ gem 'rake', '>= 10.0.0'
gem "responders"
# allows soft delete. Used for members.
gem 'discard', '>= 1.2'
gem 'discard', '~> 1.0'
gem 'xmlrpc' # fixes rake error - can be removed if not needed later
gem 'puma'
gem 'loofah', '>= 2.19.1'
gem 'loofah', '>= 2.2.1'
gem 'rack-protection', '>= 2.0.1'
# Member to member messaging system
gem 'mailboxer', '>= 0.15.1'
gem 'mailboxer'
gem 'faraday'
gem 'faraday_middleware'
@@ -165,6 +165,7 @@ group :development, :test do
gem 'dotenv-rails'
# cli utils
gem 'coveralls', require: false # coverage analysis
gem 'haml-i18n-extractor', require: false
gem 'haml_lint', '>= 0.25.1', require: false # Checks haml files for goodness
gem 'i18n-tasks', require: false # adds tests for finding missing and unused translations
@@ -174,6 +175,7 @@ end
group :test do
gem 'codeclimate-test-reporter', require: false
gem 'percy-capybara', '~> 4.0.0'
gem 'rails-controller-testing'
gem 'selenium-webdriver'
gem 'timecop'
@@ -183,5 +185,3 @@ end
group :travis do
gem 'platform-api'
end
gem "percy-capybara", "~> 5.0.0"

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
# 🌱 Growstuff
![Build status](https://github.com/Growstuff/growstuff/workflows/CI/badge.svg)
[![Build Status](https://travis-ci.org/Growstuff/growstuff.svg?branch=dev)](https://travis-ci.org/Growstuff/growstuff)
[![Coverage Status](https://coveralls.io/repos/github/Growstuff/growstuff/badge.svg?branch=dev)](https://coveralls.io/github/Growstuff/growstuff?branch=dev)
[![Code Climate](https://codeclimate.com/github/Growstuff/growstuff/badges/gpa.svg)](https://codeclimate.com/github/Growstuff/growstuff)
Welcome to the Growstuff project.

View File

@@ -7,7 +7,7 @@
bottom: 0;
color: $white;
margin: 0;
opacity: 0.8;
opacity: .8;
position: absolute;
text-align: center;
width: 100%;
@@ -22,7 +22,7 @@
h5.crop-sci-name {
background-color: $beige;
color: $black;
font-size: 0.7em;
font-size: .7em;
margin-top: 0;
padding-top: 0;
}
@@ -45,7 +45,7 @@
.planting {
.crop-card {
height: 100%;
margin: 0.1em;
margin: .1em;
min-height: 300px;
}
@@ -85,7 +85,7 @@
@include media-breakpoint-down(xs) {
.index-cards {
.crop-thumbnail {
margin: 0.2em;
margin: .2em;
width: 30%;
}
}

View File

@@ -2,7 +2,7 @@
.text {
color: $white;
margin: 0;
opacity: 0.8;
opacity: .8;
position: absolute;
text-align: center;
top: 30%;
@@ -12,7 +12,7 @@
h3,
h4,
h5 {
margin: 0;
margin: 0
}
h3 {

View File

@@ -2,7 +2,7 @@
border-radius: 12px;
height: 200px;
margin: 1em;
padding: 0.25em;
padding: .25em;
div {
display: inline-block;
@@ -11,11 +11,12 @@
}
}
.member-thumbnail div ~ div {
.member-thumbnail div~div {
padding-left: 1em;
width: 15em;
}
.member-chip {
background-color: lighten($green, 30%);
@@ -34,7 +35,7 @@
}
.location-not-set {
background-image: image-url("location-not-set.en.png");
background-image: image-url('location-not-set.en.png');
background-position: center;
background-repeat: no-repeat;
height: 250px;

View File

@@ -15,36 +15,30 @@ $body-bg: $beige;
$text-color: $brown;
$link-color: $green;
$default-font: "Raleway", "Fira Sans", Helvetica, Arial, sans-serif;
$default-font: 'Raleway',
"Fira Sans",
Helvetica,
Arial,
sans-serif;
$primary: (
color: $green,
$primary: (color: $green,
dark: darken($green, 20%),
light: lighten($green, 20%),
);
$secondary: (
color: $blue,
light: lighten($green, 20%));
$secondary: (color: $blue,
dark: darken($blue, 20%),
light: lighten($blue, 20%),
);
$success: (
color: $green,
light: lighten($blue, 20%));
$success: (color: $green,
dark: darken($green, 20%),
light: lighten($green, 20%),
);
$danger: (
color: $red,
light: lighten($green, 20%));
$danger: (color: $red,
dark: darken($red, 20%),
light: lighten($red, 20%),
);
$dark: (
color: $brown,
light: lighten($red, 20%));
$dark: (color: $brown,
dark: darken($brown, 20%),
light: lighten($brown, 20%),
);
light: lighten($brown, 20%));
$grid-breakpoints: (
// Extra small screen / phone
$grid-breakpoints: ( // Extra small screen / phone
xs: 0,
// Small screen / phone
sm: 576px,
@@ -53,8 +47,7 @@ $grid-breakpoints: (
// Large screen / desktop
lg: 1200px,
// Extra large screen / wide desktop
xl: 1800px
);
xl: 1800px);
// Nav bar
$navbar-default-bg: $brown;

View File

@@ -1,32 +1,33 @@
// Import original variables so they can be used in overrides
@import "variables";
@import "material";
@import 'variables';
@import 'material';
@import 'jquery-ui/autocomplete';
@import 'bootstrap-datepicker';
@import 'leaflet';
@import 'leaflet.markercluster';
@import "jquery-ui/autocomplete";
@import "bootstrap-datepicker";
@import "leaflet";
@import "leaflet.markercluster";
// Font Awesome
@import "font-awesome-sprockets";
@import "font-awesome";
@import "material_icons";
@import "rails_bootstrap_forms";
@import 'font-awesome-sprockets';
@import 'font-awesome';
@import 'material_icons';
@import 'rails_bootstrap_forms';
@import "overrides";
@import "mobile";
@import 'overrides';
@import 'mobile';
@import "crops";
@import "harvests";
@import "likes";
@import "members";
@import "notifications";
@import "plantings";
@import "photos";
@import "posts";
@import "seeds";
@import 'crops';
@import 'harvests';
@import 'likes';
@import 'members';
@import 'notifications';
@import 'plantings';
@import 'photos';
@import 'posts';
@import 'seeds';
@import "predictions";
@import "homepage";
@import "maps";
@import 'predictions';
@import 'homepage';
@import 'maps';

View File

@@ -1,6 +1,7 @@
// Overrides applying only to mobile view. This must be at the end of the overrides file.
// Extra small devices (portrait phones, less than 576px)
@include media-breakpoint-down(md) {
.container {
margin: 2px;
padding: 0;
@@ -10,7 +11,7 @@
width: 100%;
}
.navbar .nav > li {
.navbar .nav>li {
display: block;
}
@@ -32,10 +33,11 @@
}
.site-name:after {
content: "";
content: '';
display: inline-block;
width: 100%;
}
}
h1 {
@@ -64,13 +66,14 @@
height: 300px;
}
section .btn {
width: 100%;
}
.index-cards {
.card {
margin: 0.2em;
margin: .2em;
width: 48%;
// Shrink title to fit more on page
@@ -84,6 +87,7 @@
object-fit: cover;
width: 100%;
}
}
}
}

View File

@@ -10,9 +10,9 @@ body {
.navbar-brand {
.site-name {
font-family: "Modak", cursive;
font-family: 'Modak', cursive;
font-size: 3em;
margin: 0.3em;
margin: .3em;
}
img {
@@ -46,6 +46,7 @@ body {
font-size: 5em;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
@@ -81,8 +82,9 @@ h3 {
font-size: 120%;
}
section {
margin: 0.5em 0 0;
margin: .5em 0 0;
padding: 0 0 1em;
h2 {
@@ -90,7 +92,7 @@ section {
box-shadow: 1px 1px 1px 1px darken($beige, 20%);
color: $white;
font-weight: normal;
padding: 0.2em;
padding: .2em;
a {
color: $white;
@@ -98,16 +100,7 @@ section {
}
.card {
background: $white;
box-shadow: 1px 3px 3px 1px darken($beige, 20%);
cursor: pointer;
transition: 0.3s transform cubic-bezier(0.155, 1.105, 0.295, 1.12), 0.3s box-shadow,
0.3s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
}
.card:hover {
box-shadow: 0 10px 20px darken($beige, 30%), 0 4px 8px darken($beige, 40%);
transform: scale(1.1);
}
}
@@ -124,7 +117,7 @@ section {
.card {
background: $white;
border-radius: 5%;
margin: 0.5em 0.5em 0.5em 0;
margin: .5em .5em .5em 0;
width: 200px;
.img-card {
@@ -239,6 +232,7 @@ ul.associations {
// footer
footer {
#footer1,
#footer2,
#footer3 {
@@ -376,7 +370,7 @@ ul.thumbnail-buttons {
}
.info {
padding: 0.5em;
padding: .5em;
text-align: center;
}
}
@@ -392,7 +386,7 @@ ul.thumbnail-buttons {
display: inline-block;
height: 30px;
line-height: 30px;
margin: 0.2em;
margin: .2em;
padding: 0 25px;
a {
@@ -417,14 +411,14 @@ ul.thumbnail-buttons {
.progress-fade::before {
background: $beige;
bottom: 0;
content: "";
content: '';
display: block;
left: 0;
opacity: 0.7;
opacity: .7;
position: absolute;
right: 0;
top: 0;
transition: background 0.3s linear;
transition: background .3s linear;
}
.progress-fade:hover::before {

View File

@@ -13,6 +13,12 @@ module Admin
@members = @members.order(:login_name).paginate(page: params[:page])
end
def destroy
@member = Member.find_by!(slug: params[:slug])
@member.discard
redirect_to admin_members_path
end
def edit
@member = Member.find_by!(slug: params[:slug])
end
@@ -24,12 +30,6 @@ module Admin
respond_with @member, location: admin_members_path
end
def destroy
@member = Member.find_by!(slug: params[:slug])
@member.discard
redirect_to admin_members_path
end
private
def search_term

View File

@@ -14,14 +14,14 @@ class AuthenticationsController < ApplicationController
@authentication = current_member.authentications
.create_with(
name:,
name: name,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name:
name: name
)
flash[:notice] = "Authentication successful."

View File

@@ -7,10 +7,9 @@ class ConversationsController < ApplicationController
before_action :check_current_subject_in_conversation, only: %i(show update destroy)
def index
@conversations = case @box
when "inbox"
@conversations = if @box.eql? "inbox"
mailbox.inbox
when "sent"
elsif @box.eql? "sent"
mailbox.sentbox
else
mailbox.trash
@@ -60,7 +59,7 @@ class ConversationsController < ApplicationController
'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 },
'trash' => { 'total' => mailbox.trash.size, 'unread' => 0 }
}
@box = if params[:box].blank? || @boxes.keys.exclude?(params[:box])
@box = if params[:box].blank? || !@boxes.keys.include?(params[:box])
'inbox'
else
params[:box]
@@ -71,7 +70,7 @@ class ConversationsController < ApplicationController
@conversation = Mailboxer::Conversation.find_by(id: params[:id])
return unless @conversation.nil? || !@conversation.is_participant?(current_member)
redirect_to conversations_path(box:)
redirect_to conversations_path(box: box)
nil
end
end

View File

@@ -57,11 +57,14 @@ class CropsController < ApplicationController
@crops = CropSearchService.search(@term,
page: params[:page],
per_page: Crop.per_page,
current_member:)
current_member: current_member)
respond_with @crops
end
def show
@crop = Crop.includes(
:scientific_names, :alternate_names, :parent, :varieties
).find_by!(slug: params[:slug])
respond_to do |format|
format.html do
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
@@ -86,6 +89,7 @@ class CropsController < ApplicationController
end
def edit
@crop = Crop.find_by!(slug: params[:slug])
@crop.alternate_names.build if @crop.alternate_names.blank?
@crop.scientific_names.build if @crop.scientific_names.blank?
end
@@ -106,13 +110,14 @@ class CropsController < ApplicationController
end
def update
@crop = Crop.find_by!(slug: params[:slug])
if can?(:wrangle, @crop)
@crop.approval_status = 'rejected' if params.fetch("reject", false)
@crop.approval_status = 'approved' if params.fetch("approve", false)
end
@crop.creator = current_member if @crop.approval_status == "pending"
if @crop.update(crop_params)
recreate_names('alt_name', 'alternate')
recreate_names('sci_name', 'scientific')
@@ -140,22 +145,26 @@ class CropsController < ApplicationController
def notifier
case @crop.approval_status
when "approved"
NotifierMailer.crop_request_approved(@crop.requester, @crop)
Notifier.crop_request_approved(@crop.requester, @crop)
when "rejected"
NotifierMailer.crop_request_rejected(@crop.requester, @crop)
Notifier.crop_request_rejected(@crop.requester, @crop)
end
end
def save_crop_names
AlternateName.create!(names_params(:alt_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
ScientificName.create!(names_params(:sci_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
params[:alt_name]&.values&.each do |value|
create_name!('alternate', value) unless value.empty?
end
params[:sci_name]&.values&.each do |value|
create_name!('scientific', value) unless value.empty?
end
end
def notify_wranglers
return if current_member.role? :crop_wrangler
Role.crop_wranglers&.each do |w|
NotifierMailer.new_crop_request(w, @crop).deliver_now!
Notifier.new_crop_request(w, @crop).deliver_now!
end
end
@@ -178,20 +187,21 @@ class CropsController < ApplicationController
def crop_params
params.require(:crop).permit(
:name, :en_wikipedia_url,
:parent_id, :perennial,
:request_notes, :reason_for_rejection,
:en_wikipedia_url,
:name,
:parent_id,
:perennial,
:request_notes,
:reason_for_rejection,
:rejection_notes,
scientific_names_attributes: %i(scientific_name _destroy id)
scientific_names_attributes: %i(scientific_name
_destroy
id)
)
end
def names_params(name_type)
params.require(name_type).values&.reject { |n| n.empty? }
end
def filename
"Growstuff-Crops-#{Time.zone.now.to_fs(:number)}.csv"
"Growstuff-Crops-#{Time.zone.now.to_s(:number)}.csv"
end
def crop_json_fields
@@ -202,7 +212,8 @@ class CropsController < ApplicationController
owner: { only: %i(id login_name location latitude longitude) }
}
},
scientific_names: { only: [:name] }, alternate_names: { only: [:name] }
scientific_names: { only: [:name] },
alternate_names: { only: [:name] }
}
}
end

View File

@@ -5,10 +5,6 @@ class FollowsController < ApplicationController
load_and_authorize_resource
skip_load_resource only: :create
def index
@follows = @member.followed.paginate(page: params[:page])
end
def create
@follow = current_member.follows.build(followed: Member.find(params[:followed]))
@@ -29,6 +25,10 @@ class FollowsController < ApplicationController
redirect_to @unfollowed
end
def index
@follows = @member.followed.paginate(page: params[:page])
end
def followers
@followers = @member.followers.paginate(page: params[:page])
end

View File

@@ -20,7 +20,7 @@ class HarvestsController < DataController
where['planting_id'] = @planting.id
end
@harvests = Harvest.search('*', where:,
@harvests = Harvest.search('*', where: where,
limit: 100,
page: params[:page],
load: false,
@@ -92,7 +92,7 @@ class HarvestsController < DataController
elsif @crop
"#{@crop.to_param}-"
end
"Growstuff-#{specifics}Harvests-#{Time.zone.now.to_fs(:number)}.csv"
"Growstuff-#{specifics}Harvests-#{Time.zone.now.to_s(:number)}.csv"
end
def update_crop_medians

View File

@@ -39,7 +39,7 @@ class LikesController < ApplicationController
{
id: like.likeable.id,
like_count: like.likeable.likes.count,
liked_by_member:,
liked_by_member: liked_by_member,
description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like")
}
end
@@ -50,7 +50,7 @@ class LikesController < ApplicationController
format.json do
render(json: render_json(
like,
liked_by_member:
liked_by_member: liked_by_member
), status: status_code)
end
end

View File

@@ -18,6 +18,7 @@ class MembersController < ApplicationController
@member = Member.confirmed.kept.find_by!(slug: params[:slug])
@twitter_auth = @member.auth('twitter')
@flickr_auth = @member.auth('flickr')
@facebook_auth = @member.auth('facebook')
@posts = @member.posts
@activity = TimelineService.member_query(@member).limit(30)

View File

@@ -9,6 +9,10 @@ require './lib/actions/oauth_signup_action'
# Heavily overlaps with Authentications controller
#
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
create
end
def failure
flash[:alert] = "Authentication failed."
redirect_to request.env['omniauth.origin'] || "/"
@@ -28,7 +32,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@authentication = action.establish_authentication(auth, member)
if action.member_created?
raise "Invalid provider" unless %w(twitter flickr).index(auth['provider'].to_s)
raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s)
session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"]
sign_in member

View File

@@ -2,28 +2,36 @@
class PhotosController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
before_action :set_crop_and_planting, only: :index
after_action :expire_homepage, only: %i(create destroy)
load_and_authorize_resource
respond_to :html, :json
responders :flash
def show
@crops = Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: @photo })
respond_with(@photo)
end
def index
where = {}
if params[:crop_slug]
@crop = Crop.find params[:crop_slug]
where = { crops: @crop.id }
elsif params[:planting_id]
@planting = Planting.find params[:planting_id]
where = { planting_id: @planting.id }
end
@photos = Photo.search(
load: false,
boost_by: [:created_at],
where: index_where_clause,
where: where,
page: params[:page],
limit: Photo.per_page
)
respond_with(@photos)
end
def show
@crops = Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: @photo })
respond_with(@photo)
end
def new
@photo = Photo.new
@item = item_to_link_to
@@ -92,15 +100,8 @@ class PhotosController < ApplicationController
def retrieve_from_flickr
@flickr_auth = current_member.auth('flickr')
return if @flickr_auth.nil?
unless current_member.flickr_auth_valid?
current_member.remove_stale_flickr_auth
@please_reconnect_flickr = true
return
end
@current_set = params[:set]
return unless @flickr_auth
page = params[:page] || 1
@@ -111,19 +112,4 @@ class PhotosController < ApplicationController
pager.replace photos
end
end
def index_where_clause
if params[:crop_slug]
{ crops: @crop.id }
elsif params[:planting_id]
{ planting_id: @planting.id }
else
{}
end
end
def set_crop_and_planting
@crop = Crop.find params[:crop_slug] if params[:crop_slug]
@planting = Planting.find params[:planting_id] if params[:planting_id]
end
end

View File

@@ -17,18 +17,18 @@ class PlantingsController < DataController
if params[:crop_slug]
@crop = Crop.find_by(slug: params[:crop_slug])
where['crop_id'] = @crop.id unless @crop.nil?
where['crop_id'] = @crop.id
end
@plantings = Planting.search(
where:,
where: where,
page: params[:page],
limit: 30,
boost_by: [:created_at],
load: false
)
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_fs(:number)}.csv"
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"
respond_with(@plantings)
end

View File

@@ -6,6 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
def edit
@twitter_auth = current_member.auth('twitter')
@flickr_auth = current_member.auth('flickr')
@facebook_auth = current_member.auth('facebook')
render "edit"
end

View File

@@ -24,7 +24,7 @@ class SeedsController < DataController
@filename = csv_filename
@seeds = Seed.search(
where:,
where: where,
page: params[:page],
limit: 30,
boost_by: [:created_at],
@@ -89,9 +89,9 @@ class SeedsController < DataController
def csv_filename
if @owner
"Growstuff-#{@owner.to_param}-Seeds-#{Time.zone.now.to_fs(:number)}.csv"
"Growstuff-#{@owner.to_param}-Seeds-#{Time.zone.now.to_s(:number)}.csv"
else
"Growstuff-Seeds-#{Time.zone.now.to_fs(:number)}.csv"
"Growstuff-Seeds-#{Time.zone.now.to_s(:number)}.csv"
end
end
end

View File

@@ -24,14 +24,14 @@ module ApplicationHelper
# Produces a cache key for uniquely identifying cached fragments.
def cache_key_for(klass, identifier = "all")
count = klass.count
max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_fs, :number)
max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number)
"#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}"
end
def required_field_help_text
asterisk = tag.span('*', class: ['red'])
text = tag.em('denotes a required field')
tag.div(asterisk + ' '.html_safe + text, class: ['margin-bottom'])
asterisk = content_tag :span, '*', class: ['red']
text = content_tag :em, 'denotes a required field'
content_tag :div, asterisk + ' '.html_safe + text, class: ['margin-bottom']
end
#
@@ -55,7 +55,7 @@ module ApplicationHelper
return uri.to_s
end
Gravatar.new(member.email).image_url(size:,
Gravatar.new(member.email).image_url(size: size,
default: :identicon,
ssl: true)
end
@@ -69,13 +69,14 @@ module ApplicationHelper
def show_inactive_tickbox_path(type, owner: nil, crop: nil, show_all: false)
all = show_all ? '' : 1
if owner.present?
public_send("member_#{type}_path", owner, all:)
elsif crop.present?
public_send("crop_#{type}_path", crop, all:)
else
public_send("#{type}_path", all:)
end
path = if owner.present?
public_send("member_#{type}_path", owner, all: all)
elsif crop.present?
public_send("crop_#{type}_path", crop, all: all)
else
public_send("#{type}_path", all: all)
end
path
end
def title(type, owner, crop, planting)

View File

@@ -44,19 +44,19 @@ module ButtonsHelper
end
def seed_edit_button(seed, classes: "btn btn-raised btn-info")
edit_button(edit_seed_path(seed), classes:)
edit_button(edit_seed_path(seed), classes: classes)
end
def harvest_edit_button(harvest, classes: "btn btn-raised btn-info")
edit_button(edit_harvest_path(harvest), classes:)
edit_button(edit_harvest_path(harvest), classes: classes)
end
def garden_edit_button(garden, classes: "btn btn-raised btn-info")
edit_button(edit_garden_path(garden), classes:)
edit_button(edit_garden_path(garden), classes: classes)
end
def planting_edit_button(planting, classes: "btn btn-raised btn-info")
edit_button(edit_planting_path(planting), classes:)
edit_button(edit_planting_path(planting), classes: classes)
end
def planting_finish_button(planting, classes: 'btn btn-default btn-secondary')

View File

@@ -2,7 +2,7 @@
module CropsHelper
def display_seed_availability(member, crop)
seeds = member.seeds.where(crop:)
seeds = member.seeds.where(crop: crop)
total_quantity = seeds.where.not(quantity: nil).sum(:quantity)
return "You don't have any seeds of this crop." if seeds.none?

View File

@@ -2,7 +2,7 @@
module EditableFormHelper
def editable(field_type, model, field, display_field:, collection: [])
render 'shared/editable/form', field_type:,
model:, field:, display_field:, collection:
render 'shared/editable/form', field_type: field_type,
model: model, field: field, display_field: display_field, collection: collection
end
end

View File

@@ -2,11 +2,11 @@
module PostsHelper
def display_post_truncated(post, length: 300)
truncate(strip_tags(post.body), length:,
truncate(strip_tags(post.body), length: length,
separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
end
def post_stripped_tags(post, length: 300)
truncate(strip_tags(post.body), length:)
truncate(strip_tags(post.body), length: length)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class NotifierMailer < ApplicationMailer
class Notifier < ApplicationMailer
# include NotificationsHelper
default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>"

View File

@@ -70,7 +70,7 @@ class Ability
can :create, Notification do |n|
n.recipient_id != member.id
end
# NOTE: we don't support update for notifications
# note we don't support update for notifications
# only crop wranglers can create/edit/destroy crops
if member.role? :crop_wrangler

View File

@@ -4,7 +4,7 @@ class Comment < ApplicationRecord
belongs_to :author, class_name: 'Member', inverse_of: :comments
belongs_to :post, counter_cache: true
scope :post_order, -> { order(created_at: :asc) } # for display on post page
scope :post_order, -> { reorder("created_at ASC") } # for display on post page
after_create do
recipient = post.author.id
@@ -15,7 +15,7 @@ class Comment < ApplicationRecord
recipient_id: recipient,
sender_id: sender,
subject: "#{author} commented on #{post.subject}",
body:,
body: body,
post_id: post.id
)
end

View File

@@ -19,24 +19,6 @@ module MemberFlickr
@flickr
end
def flickr_auth_valid?
# no flickr token saved for this member
return false if flickr.nil?
# test the token/secret we have
flickr.test.login # This throws exception if fails
# success!
true
rescue FlickRaw::FailedResponse, FlickRaw::OAuthClient::FailedResponse
# token for this user doesn't work
false
end
def remove_stale_flickr_auth
authentications.find_by(provider: "flickr")&.delete
end
# Fetches a collection of photos from Flickr
# Returns a [[page of photos], total] pair.
# Total is needed for pagination.

View File

@@ -32,8 +32,8 @@ module MemberNewsletter
gibbon.lists.subscribe(
id: Rails.application.config.newsletter_list_id,
email: { email: },
merge_vars: { login_name: },
email: { email: email },
merge_vars: { login_name: login_name },
double_optin: false # they already confirmed their email with us
)
end
@@ -42,7 +42,7 @@ module MemberNewsletter
return true if Rails.env.test? && !testing
gibbon.lists.unsubscribe(id: Rails.application.config.newsletter_list_id,
email: { email: })
email: { email: email })
end
end
end

View File

@@ -4,7 +4,8 @@ module Ownable
extend ActiveSupport::Concern
included do
belongs_to :owner, class_name: 'Member', counter_cache: true
belongs_to :owner, class_name: 'Member',
foreign_key: 'owner_id', counter_cache: true
default_scope { joins(:owner).merge(Member.kept) } # Ensures the owner still exists
end

View File

@@ -33,7 +33,7 @@ module PredictHarvest
days_to_first_harvest = (first_harvest_date - planted_at).to_i
days_to_last_harvest = (last_harvest_date - planted_at).to_i if finished?
end
update(days_to_first_harvest:, days_to_last_harvest:)
update(days_to_first_harvest: days_to_first_harvest, days_to_last_harvest: days_to_last_harvest)
end
# status

View File

@@ -29,19 +29,19 @@ module SearchCrops
def search_data
{
name:,
description:,
slug:,
name: name,
description: description,
slug: slug,
alternate_names: alternate_names.pluck(:name),
scientific_names: scientific_names.pluck(:name),
photos_count: photo_associations_count,
# boost the crops that are planted the most
plantings_count:,
harvests_count:,
plantings_count: plantings_count,
harvests_count: harvests_count,
# boost this crop for these members
planters_ids: plantings.pluck(:owner_id),
has_photos: photos.size.positive?,
thumbnail_url:,
thumbnail_url: thumbnail_url,
scientific_name: default_scientific_name&.name,
created_at: created_at.to_i
}

View File

@@ -17,22 +17,22 @@ module SearchHarvests
def search_data
{
slug:,
quantity:,
slug: slug,
quantity: quantity,
# crop
crop_id:,
crop_name:,
crop_id: crop_id,
crop_name: crop_name,
crop_slug: crop.slug,
# owner
owner_id:,
owner_login_name:,
owner_slug:,
owner_id: owner_id,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
plant_part_name: plant_part&.name,
# planting
planting_id:,
planting_id: planting_id,
planting_slug: planting&.slug,
# photo
@@ -43,7 +43,7 @@ module SearchHarvests
photos_count: photos.count,
# timestamps
harvested_at:,
harvested_at: harvested_at,
created_at: created_at.to_i
}
end
@@ -58,7 +58,7 @@ module SearchHarvests
}
one_record = search('*',
limit: 1,
where:,
where: where,
boost_by: [:created_at],
load: false).first
return records if one_record.nil?

View File

@@ -15,20 +15,20 @@ module SearchPhotos
def search_data
{
id:,
title:,
thumbnail_url:,
fullsize_url:,
id: id,
title: title,
thumbnail_url: thumbnail_url,
fullsize_url: fullsize_url,
# crops
crops: crops.pluck(:id),
# likes
liked_by_members_names:,
liked_by_members_names: liked_by_members_names,
# owner
owner_id:,
owner_login_name:,
owner_slug:,
owner_id: owner_id,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
# counts
likes_count:,
likes_count: likes_count,
created_at: created_at.to_i
}

View File

@@ -18,39 +18,39 @@ module SearchPlantings
def search_data
{
slug:,
active:,
slug: slug,
active: active,
finished: finished?,
has_photos: photos.size.positive?,
location:,
location: location,
percentage_grown: percentage_grown.to_i,
planted_at:,
planted_from:,
planted_at: planted_at,
planted_from: planted_from,
planted_year: planted_at&.year,
quantity:,
sunniness:,
garden_id:,
quantity: quantity,
sunniness: sunniness,
garden_id: garden_id,
first_harvest_predicted_at:,
finish_predicted_at:,
first_harvest_predicted_at: first_harvest_predicted_at,
finish_predicted_at: finish_predicted_at,
# crops
crop_id:,
crop_name:,
crop_slug:,
crop_perennial:,
crop_id: crop_id,
crop_name: crop_name,
crop_slug: crop_slug,
crop_perennial: crop_perennial,
# owner
owner_id:,
owner_location:,
owner_login_name:,
owner_slug:,
owner_id: owner_id,
owner_location: owner_location,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
# photos
thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url,
# counts
photos_count: photos.size,
harvests_count:,
harvests_count: harvests_count,
# timestamps
created_at: created_at.to_i
@@ -67,7 +67,7 @@ module SearchPlantings
}
one_record = search('*',
limit: 1,
where:,
where: where,
boost_by: [:created_at],
load: false).first
return records if one_record.nil?

View File

@@ -18,31 +18,31 @@ module SearchSeeds
def search_data
{
slug:,
slug: slug,
finished: finished?,
gmo:,
active:,
heirloom:,
gmo: gmo,
active: active,
heirloom: heirloom,
location: owner.location,
organic:,
quantity:,
plant_before: plant_before&.to_fs(:ymd),
tradable_to:,
tradable:,
organic: organic,
quantity: quantity,
plant_before: plant_before&.to_s(:ymd),
tradable_to: tradable_to,
tradable: tradable,
# crop
crop_id:,
crop_id: crop_id,
crop_name: crop.name,
crop_slug: crop.slug,
# owner
owner_id:,
owner_location:,
owner_login_name:,
owner_slug:,
owner_id: owner_id,
owner_location: owner_location,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
# planting
parent_planting:,
parent_planting: parent_planting,
# counts
photos_count: photos.size,
@@ -56,7 +56,7 @@ module SearchSeeds
end
def self.homepage_records(limit)
search('*', limit:,
search('*', limit: limit,
where: {
finished: false,
tradable: true

View File

@@ -50,7 +50,7 @@ class Crop < ApplicationRecord
## Wikipedia urls are only necessary when approving a crop
validates :en_wikipedia_url,
format: {
with: %r{\Ahttps?://en\.wikipedia\.org/wiki/[[:alnum:]%_.()-]+\z},
with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z},
message: 'is not a valid English Wikipedia URL'
},
if: :approved?

View File

@@ -10,9 +10,9 @@ class CsvImporter
def import_crop(row)
name, en_wikipedia_url, parent_name, scientific_names, alternate_names = row
@crop = Crop.find_or_create_by(name:)
@crop = Crop.find_or_create_by(name: name)
@crop.update(
en_wikipedia_url:,
en_wikipedia_url: en_wikipedia_url,
creator_id: cropbot.id
)
@@ -47,8 +47,8 @@ class CsvImporter
return if names_to_add.empty?
names_to_add.each do |name|
sciname = ScientificName.find_by(name:, crop: @crop)
sciname ||= ScientificName.create!(name:, crop: @crop, creator: cropbot)
sciname = ScientificName.find_by(name: name, crop: @crop)
sciname ||= ScientificName.create!(name: name, crop: @crop, creator: cropbot)
@crop.scientific_names << sciname
end
end
@@ -58,7 +58,7 @@ class CsvImporter
return if alternate_names.blank?
alternate_names.split(/,\s*/).each do |name|
altname = AlternateName.find_by(name:, crop: @crop)
altname = AlternateName.find_by(name: name, crop: @crop)
altname ||= AlternateName.create! name: name, crop: @crop, creator: cropbot
@crop.alternate_names << altname
end

View File

@@ -14,8 +14,6 @@ class Garden < ApplicationRecord
# set up geocoding
geocoded_by :location
before_validation :strip_blanks
after_validation :cleanup_area
after_validation :geocode
after_validation :empty_unwanted_geocodes
after_save :mark_inactive_garden_plantings_as_finished
@@ -27,6 +25,7 @@ class Garden < ApplicationRecord
validates :location, length: { maximum: 255 }
validates :slug, uniqueness: true
before_validation :strip_blanks
validates :name, uniqueness: { scope: :owner_id }
validates :name,
format: { without: /\n/, message: "must contain no newlines" },
@@ -52,6 +51,8 @@ class Garden < ApplicationRecord
message: "%<value>s is not a valid area unit" },
allow_blank: true
after_validation :cleanup_area
def cleanup_area
self.area = nil if area&.zero?
self.area_unit = nil if area.blank?

View File

@@ -21,7 +21,7 @@ class Member < ApplicationRecord
has_many :harvests, foreign_key: 'owner_id', dependent: :destroy, inverse_of: :owner
has_and_belongs_to_many :roles
has_many :notifications, foreign_key: 'recipient_id', inverse_of: :recipient
has_many :sent_notifications, foreign_key: 'sender_id', inverse_of: :sender, class_name: "Notification"
has_many :sent_notifications, foreign_key: 'sender_id', inverse_of: :sender
has_many :authentications, dependent: :destroy
has_many :photos, inverse_of: :owner
has_many :likes, dependent: :destroy
@@ -127,7 +127,7 @@ class Member < ApplicationRecord
end
def auth(provider)
authentications.find_by(provider:)
authentications.find_by(provider: provider)
end
def unread_count

View File

@@ -7,7 +7,7 @@ class Photo < ApplicationRecord
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo
# This doesn't work, ActiveRecord tries to use the polymoriphinc photographable
# relationship instead.
@@ -27,7 +27,7 @@ class Photo < ApplicationRecord
source_type: type
end
scope :by_crop, ->(crop) { joins(:photo_associations).where(photo_associations: { crop: }) }
scope :by_crop, ->(crop) { joins(:photo_associations).where(photo_associations: { crop: crop }) }
scope :by_model, lambda { |model_name|
joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s })
}

View File

@@ -33,8 +33,8 @@ class PhotoAssociation < ApplicationRecord
end
def crop_present
return unless %w(Planting Seed Harvest).include?(photographable_type)
errors.add(:crop_id, "failed to calculate crop") if crop_id.blank?
if %w(Planting Seed Harvest).include?(photographable_type)
errors.add(:crop_id, "failed to calculate crop") if crop_id.blank?
end
end
end

View File

@@ -25,9 +25,10 @@ class Planting < ApplicationRecord
#
# Ancestry of food
belongs_to :parent_seed, class_name: 'Seed', # parent,
optional: true,
inverse_of: :child_plantings
belongs_to :parent_seed, class_name: 'Seed', # parent
foreign_key: 'parent_seed_id',
optional: true,
inverse_of: :child_plantings
has_many :child_seeds, class_name: 'Seed', # children
foreign_key: 'parent_planting_id',
inverse_of: :parent_planting,
@@ -89,7 +90,7 @@ class Planting < ApplicationRecord
# stringify as "beet in Skud's backyard" or similar
def to_s
I18n.t('plantings.string', crop: crop.name, garden: garden.name, owner:)
I18n.t('plantings.string', crop: crop.name, garden: garden.name, owner: owner)
end
def finished?
@@ -109,7 +110,7 @@ class Planting < ApplicationRecord
# latitude, longitude = Geocoder.coordinates(location, params: { limit: 1 })
Planting.joins(:garden)
.where(crop:)
.where(crop: crop)
.located
.where('gardens.latitude < ? AND gardens.latitude > ?',
latitude + 10, latitude - 10)

View File

@@ -14,10 +14,10 @@ class Post < ApplicationRecord
has_many :crop_posts, dependent: :delete_all
has_many :crops, through: :crop_posts
after_create :send_notification
#
# Triggers
after_save :update_crop_posts_association
after_create :send_notification
default_scope { joins(:author).merge(Member.kept) } # Ensures the owner still exists
@@ -68,7 +68,7 @@ class Post < ApplicationRecord
crop_name = Regexp.last_match(1)
crop = Crop.case_insensitive_name(crop_name).first
# create association
crops << crop if crop && crops.exclude?(crop)
crops << crop if crop && !crops.include?(crop)
end
end
@@ -78,22 +78,22 @@ class Post < ApplicationRecord
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |_m|
# find member case-insensitively and add to list of recipients
member = Member.case_insensitive_login_name(Regexp.last_match(1)).first
recipients << member if member && recipients.exclude?(member)
recipients << member if member && !recipients.include?(member)
end
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_AT_REGEX) do |_m|
# find member case-insensitively and add to list of recipients
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..]).first
recipients << member if member && recipients.exclude?(member)
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..-1]).first
recipients << member if member && !recipients.include?(member)
end
# don't send notifications to yourself
recipients.map(&:id).each do |recipient_id|
next unless recipient_id != sender
Notification.create(
recipient_id:,
recipient_id: recipient_id,
sender_id: sender,
subject: "#{author} mentioned you in their post #{subject}",
body:
body: body
)
end
end

View File

@@ -11,7 +11,7 @@ class Role < ApplicationRecord
%i(crop_wranglers admins).each do |method|
define_method method do
slug = method.to_s.singularize.dasherize
Role.where(slug:).try(:first).try(:members)
Role.where(slug: slug).try(:first).try(:members)
end
end
end

View File

@@ -16,7 +16,7 @@ class Seed < ApplicationRecord
#
# Relationships
belongs_to :crop
belongs_to :parent_planting, class_name: 'Planting',
belongs_to :parent_planting, class_name: 'Planting', foreign_key: 'parent_planting_id',
optional: true, inverse_of: :child_seeds # parent
has_many :child_plantings, class_name: 'Planting',
foreign_key: 'parent_seed_id', dependent: :nullify,
@@ -69,6 +69,6 @@ class Seed < ApplicationRecord
end
def to_s
I18n.t('seeds.string', crop: crop.name, owner:)
I18n.t('seeds.string', crop: crop.name, owner: owner)
end
end

View File

@@ -5,10 +5,10 @@ module Api
class MemberResource < BaseResource
immutable
has_many :gardens, foreign_key: 'owner_id'
has_many :plantings, foreign_key: 'owner_id'
has_many :harvests, foreign_key: 'owner_id'
has_many :seeds, foreign_key: 'owner_id'
has_many :gardens
has_many :plantings
has_many :harvests
has_many :seeds
has_many :photos

View File

@@ -33,7 +33,6 @@ module Api
filter :planted_from
filter :garden
filter :owner
filter :owner_id
filter :finished
attribute :percentage_grown

View File

@@ -4,8 +4,8 @@ class CropSearchService
# Crop.search(string)
def self.search(query, page: 1, per_page: 12, current_member: nil)
search_params = {
page:,
per_page:,
page: page,
per_page: per_page,
fields: %i(name^5 alternate_names scientific_names),
match: :word_start,
boost_by: [:plantings_count],
@@ -16,28 +16,28 @@ class CropSearchService
# prioritise crops the member has planted
search_params[:boost_where] = { planters_ids: current_member.id } if current_member
Crop.search(query, **search_params)
Crop.search(query, search_params)
end
def self.random_with_photos(limit)
body = {
query: {
function_score: {
query: { query_string: { query: 'has_photos:true' } },
random_score: { seed: DateTime.now.to_i }
"query": {
"function_score": {
"query": { "query_string": { "query": 'has_photos:true' } },
"random_score": { "seed": DateTime.now.to_i }
}
}
}
Crop.search(
limit:,
limit: limit,
load: false,
body:
body: body
)
end
def self.recent(limit)
Crop.search(
limit:,
limit: limit,
load: false,
boost_by: { created_at: { factor: 100 } } # default factor is 1
)

View File

@@ -10,7 +10,7 @@ class OpenfarmService
def import!
Crop.all.order(updated_at: :desc).each do |crop|
Rails.logger.debug { "#{crop.id}, #{crop.name}" }
Rails.logger.debug("#{crop.id}, #{crop.name}")
update_crop(crop) if crop.valid?
end
end
@@ -64,9 +64,9 @@ class OpenfarmService
if photo.valid?
Photo.transaction do
photo.save
PhotoAssociation.find_or_create_by! photo:, photographable: crop
PhotoAssociation.find_or_create_by! photo: photo, photographable: crop
end
Rails.logger.debug { "\t saved photo #{photo.id} #{photo.source_id}" }
Rails.logger.debug "\t saved photo #{photo.id} #{photo.source_id}"
else
Rails.logger.warn "Photo not valid"
end

View File

@@ -2,6 +2,6 @@
class ApprovedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, _value)
record.errors.add(attribute, options[:message] || 'must be approved') unless record.crop.try(:approved?)
record.errors[attribute] << (options[:message] || 'must be approved') unless record.crop.try(:approved?)
end
end

View File

@@ -16,6 +16,6 @@
:escaped_markdown
#{ strip_tags comment.body }
%pubdate= comment.created_at.to_fs(:rfc822)
%pubdate= comment.created_at.to_s(:rfc822)
%link= post_url(comment.post)
%guid= comment_url(comment)

View File

@@ -22,7 +22,7 @@
- else
Nobody is growing this yet. You could be the first!
- if @crop.description.present?
%p= simple_format @crop.description
%p= @crop.description
.col-md-3
= image_tag crop_image_path(@crop),
class: 'img-responsive shadow rounded crop-hero-photo', alt: 'photo of crop'

View File

@@ -107,8 +107,8 @@ csv.headers *all_headers
csv.cell :added_by_member_id, c.creator.id
csv.cell :added_by_member_name, c.creator.to_s
csv.cell :date_added, c.created_at.to_fs(:db)
csv.cell :last_modified, c.updated_at.to_fs(:db)
csv.cell :date_added, c.created_at.to_s(:db)
csv.cell :last_modified, c.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"

View File

@@ -6,6 +6,6 @@
- @crops.each do |crop|
%item
%title= crop.name
%pubdate= crop.created_at.to_fs(:rfc822)
%pubdate= crop.created_at.to_s(:rfc822)
%link= crop_url(crop)
%guid= crop_url(crop)

View File

@@ -34,21 +34,18 @@
= cute_icon
= render 'crops/photos', crop: @crop
- if @crop.plantings.any? or @crop.harvests.any?
- if @crop.plantings.any?
%section.charts
.row
- if @crop.sunniness.any?
.col-lg-4.col-12
%h2 Sunniness
= pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom"
- if @crop.planted_from.any?
.col-lg-4.col-12
%h2 Planted from
= pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom"
- if @crop.harvests.any?
.col-lg-4.col-12
%h2 Harvested for
= pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Sunniness
= pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Planted from
= pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Harvested for
= pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom"
- if @crop.varieties.any?
%section.varieties

View File

@@ -28,3 +28,17 @@
method: :delete, class: "remove btn btn-danger"
- else
= link_to 'Connect to Flickr', '/members/auth/flickr', class: 'btn'
.row
.col-md-12
%p
= image_tag "facebook_32.png", size: "32x32", alt: 'Facebook logo'
- if @facebook_auth
You are connected to Facebook as
= succeed "." do
= link_to @facebook_auth.name, "https://facebook.com/profile/#{@facebook_auth.uid}"
= link_to "Disconnect", @facebook_auth,
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove btn btn-danger"
- else
= link_to 'Connect to Facebook', '/members/auth/facebook', class: 'btn'

View File

@@ -31,7 +31,7 @@
= link_to "Request new crops.", new_crop_path
.col-md-4
= f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '',
= f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '',
class: 'add-datepicker', label: 'When?'
.col-12
= f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do

View File

@@ -34,12 +34,12 @@ csv.headers :id,
csv.cells :quantity, :unit, :weight_quantity, :weight_unit, :si_weight
csv.cell :date_harvested, h.created_at.to_fs(:db)
csv.cell :date_harvested, h.created_at.to_s(:db)
csv.cell :description
csv.cell :date_added, h.created_at.to_fs(:db)
csv.cell :last_modified, h.updated_at.to_fs(:db)
csv.cell :date_added, h.created_at.to_s(:db)
csv.cell :last_modified, h.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"

View File

@@ -30,6 +30,6 @@
= csrf_meta_tags
= stylesheet_link_tag "application", media: "all"
%link{ href: path_to_image("growstuff-apple-touch-icon-precomposed.png"), rel: "apple-touch-icon-precomposed" }
%link{ href: "/growstuff-apple-touch-icon-precomposed.png", rel: "apple-touch-icon-precomposed" }
%link{ href: "https://fonts.googleapis.com/css?family=Modak|Raleway&display=swap", rel: "stylesheet" }
= favicon_link_tag 'favicon.ico'

View File

@@ -1,4 +1,4 @@
- if twitter_auth || flickr_auth || member.show_email
- if twitter_auth || flickr_auth || facebook_auth || member.show_email
%h4 Contact
- if twitter_auth
@@ -11,6 +11,11 @@
= image_tag "flickr_32.png", size: "32x32", alt: 'Flickr logo'
= link_to flickr_auth.name, "https://flickr.com/photos/#{flickr_auth.uid}"
- if facebook_auth
%p
= image_tag "facebook_32.png", size: "32x32", alt: 'Facebook logo'
= link_to facebook_auth.name, "https://facebook.com/profile/#{facebook_auth.uid}"
- if member.show_email
%p
Email:

View File

@@ -2,39 +2,39 @@
%h3 Activity
%ul.list-group.list-group-flush
%li.list-group-item
- if member.gardens.present?
- if !member.gardens.empty?
= link_to localize_plural(member.gardens, Garden), member_gardens_path(member)
- else
0 gardens
%li.list-group-item
- if member.plantings.present?
- if !member.plantings.empty?
= link_to localize_plural(member.plantings, Planting), member_plantings_path(member)
- else
0 plantings
%li.list-group-item
- if member.harvests.present?
- if !member.harvests.empty?
= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member)
- else
0 harvests
%li.list-group-item
- if member.seeds.present?
- if !member.seeds.empty?
= link_to localize_plural(member.seeds, Seed), member_seeds_path(member)
- else
0 seeds
%li.list-group-item
- if member.posts.present?
- if !member.posts.empty?
= link_to localize_plural(member.posts, Post), member_posts_path(member)
- else
0 posts
%li.list-group-item
- if member.followed.present?
- if !member.followed.empty?
= link_to localize_plural(member.followed, Follow), member_follows_path(member)
- else
0 following
%li.list-group-item
- if member.followers.present?
- if !member.followers.empty?
= link_to pluralize(member.followers.size, "follower"), member_followers_path(member)
- else
0 followers

View File

@@ -30,7 +30,7 @@
= truncate(@member.location, length: 25, separator: ' ', omission: '... ')
%p
%strong Member since
= @member.created_at.to_fs(:date)
= @member.created_at.to_s(:date)
%p
%strong Last Login
= @member.last_sign_in_at
@@ -57,7 +57,8 @@
= render "stats", member: @member
.card-footer
= render "contact", member: @member, twitter_auth: @twitter_auth,
flickr_auth: @flickr_auth
flickr_auth: @flickr_auth,
facebook_auth: @facebook_auth
.col-md-10
%section= render "map", member: @member

View File

@@ -6,7 +6,7 @@
- @member.posts.each do |post|
%item
%title #{post.subject} by #{post.author.login_name}
%pubdate= post.created_at.to_fs(:rfc822)
%pubdate= post.created_at.to_s(:rfc822)
%link= post_url(post)
%guid= post_url(post)
%description

View File

@@ -3,17 +3,7 @@
%h1 New Photo
%h2 Choose photo for #{link_to @item, @item}
- if @please_reconnect_flickr
%h2.alert Please reconnect your flickr account
%p the token has expired or been revoked.
= link_to '/members/auth/flickr', class: "btn btn-lg" do
= icon 'fab', 'flickr'
Reconnect Flickr
- elsif @flickr_auth
- if @flickr_auth
%p
Connected to Flickr as
= succeed "." do
@@ -47,9 +37,7 @@
.row.pagination
.col-md-12= will_paginate @photos
- else
%h2.alert You must connect your account to Flickr to add photos.
%p
= link_to '/members/auth/flickr', class: :btn do
= icon 'fab', 'flickr'
connect to Flickr
.alert
You must
= link_to "connect your account to Flickr", '/members/auth/flickr'
to add photos.

View File

@@ -2,3 +2,5 @@ Map data &copy;
= link_to "OpenStreetMap", "https://openstreetmap.org"
contributors under
= link_to "ODbL", "https://www.openstreetmap.org/copyright"
| Imagery &copy;
= link_to "CloudMade", "https://cloudmade.com"

View File

@@ -34,7 +34,7 @@
= link_to "Add a garden.", new_garden_path
.col-md-4
= f.text_field :planted_at,
value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '',
value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '',
class: 'add-datepicker', label: 'When?'
.row
@@ -52,7 +52,7 @@
%span.help-block= t('.finish_helper')
.col-md-6
= f.text_field :finished_at,
value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '',
value: @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '',
class: 'add-datepicker',
label: 'Finished date',
placeholder: 'optional'

View File

@@ -34,15 +34,15 @@ csv.headers :id,
csv.cells :quantity, :planted_from, :sunniness
csv.cell :date_planted, p.planted_at ? p.planted_at.to_fs(:db) : ''
csv.cell :date_planted, p.planted_at ? p.planted_at.to_s(:db) : ''
csv.cell :finished
csv.cell :date_finished, p.finished_at ? p.finished_at.to_fs(:db) : ''
csv.cell :date_finished, p.finished_at ? p.finished_at.to_s(:db) : ''
csv.cell :description
csv.cell :date_added, p.created_at.to_fs(:db)
csv.cell :last_modified, p.updated_at.to_fs(:db)
csv.cell :date_added, p.created_at.to_s(:db)
csv.cell :last_modified, p.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"

View File

@@ -7,7 +7,7 @@
- @plantings.each do |planting|
%item
%title #{planting['crop_name']} in #{planting['location']}
%pubdate= planting['created_at'].to_fs(:rfc822)
%pubdate= planting['created_at'].to_s(:rfc822)
%description
:escaped
<p>Quantity: #{planting['quantity'] ? planting['quantity'] : 'unknown' }</p>

View File

@@ -10,6 +10,6 @@
%description
:escaped_markdown
#{ strip_tags post.body }
%pubdate= post.created_at.to_fs(:rfc822)
%pubdate= post.created_at.to_s(:rfc822)
%link= post_url(post)
%guid= post_url(post)

View File

@@ -17,6 +17,6 @@
:escaped_markdown
#{ strip_tags comment.body }
%pubdate= comment.created_at.to_fs(:rfc822)
%pubdate= comment.created_at.to_s(:rfc822)
%link= post_url(@post)
%guid= comment_url(comment)

View File

@@ -30,18 +30,18 @@
.row
.col-12.col-md-4
= f.text_field :saved_at,
value: @seed.saved_at ? @seed.saved_at.to_fs(:ymd) : '',
value: @seed.saved_at ? @seed.saved_at.to_s(:ymd) : '',
class: 'add-datepicker', label: 'When were the seeds harvested/saved?'
.col-12.col-md-4= f.number_field :quantity, label: 'Quantity'
.col-12.col-md-4
= f.text_field :plant_before, class: 'add-datepicker',
value: @seed.plant_before ? @seed.plant_before.to_fs(:ymd) : ''
value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : ''
.row
.col-12.col-md-4
= f.check_box :finished, label: 'Mark as finished'
.col-12.col-md-4
= f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_fs(:ymd) : ''
= f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : ''
.col-12.col-md-4
%span.help-inline= t('.finish_helper')

View File

@@ -44,8 +44,8 @@ csv.headers :id,
csv.cell :gmo
csv.cell :heirloom
csv.cell :date_added, s.created_at.to_fs(:db)
csv.cell :last_modified, s.updated_at.to_fs(:db)
csv.cell :date_added, s.created_at.to_s(:db)
csv.cell :last_modified, s.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"

View File

@@ -7,7 +7,7 @@
- @seeds.each do |seed|
%item
%title #{seed.owner_login_name}'s #{seed.crop_name} seeds
%pubdate= seed.created_at.to_fs(:rfc822)
%pubdate= seed.created_at.to_s(:rfc822)
%description
:escaped
<p>Quantity: #{seed.quantity ||= 'unknown' }</p>

View File

@@ -6,6 +6,6 @@
.hide{id: "date--#{model.id}-#{field.to_s}"}
= bootstrap_form_for(model) do |f|
= f.text_field field,
value: model.send(field) ? model.send(field).to_fs(:ymd) : '',
value: model.send(field) ? model.send(field).to_s(:ymd) : '',
class: 'add-datepicker', label: 'When?'
= f.submit :save

View File

@@ -13,6 +13,6 @@
= f.select field, collection
- elsif field_type == :date
= f.text_field field,
value: model.send(field) ? model.send(field).to_fs(:ymd) : '',
value: model.send(field) ? model.send(field).to_s(:ymd) : '',
class: 'add-datepicker', label: 'When?'
= f.submit :save

View File

@@ -2,6 +2,7 @@
# frozen_string_literal: true
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
@@ -10,31 +11,24 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "Install JavaScript dependencies"
system('bin/yarn')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "\n== Copying sample files =="
unless File.exist?('config/database.yml')
FileUtils.cp 'config/database.yml.example', 'config/database.yml'
end
unless File.exist?('.env')
FileUtils.cp 'env-example', '.env'
end
puts "\n== Checking for elastic search =="
system! 'script/check_elasticsearch.sh'
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

View File

@@ -2,5 +2,5 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('config/environment', __dir__)
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@@ -12,12 +12,24 @@ Bundler.require(*Rails.groups)
module Growstuff
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
I18n.config.enforce_available_locales = true
config.active_record.legacy_connection_handling = false
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'UTC'
@@ -40,6 +52,17 @@ module Growstuff
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
@@ -70,6 +93,17 @@ module Growstuff
Gibbon::API.throws_exceptions = false
config.newsletter_list_id = ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID']
# This is Growstuff's global Cloudmade key. If you fork Growstuff for
# another project/website not run by the folks at http://growstuff.org/,
# then please change this key. (You can get one of your own at
# http://account.cloudmade.com/ and it's free/gratis for up to 500k tiles.)
# We'd much prefer to set this as an environment variable (as we do
# with most other things) but it turns out those aren't available at
# asset compile time on Heroku, when we need this to insert into our
# Javascript. Sigh. And yes, we know about user-env-compile but it
# didn't work for us.
config.cloudmade_key = '29a2d9e3cb3d429490a8f338b2388b1d'
# config.active_record.raise_in_transactional_callbacks = true
config.middleware.insert_before 0, Rack::Cors do
allow do

Some files were not shown because too many files have changed in this diff Show More