Files
mapknitter/app/controllers/front_ui_controller.rb
Alicia Paz d2d45dbf42 Migrate from Travis to GitHub Actions for CI (#1534)
* Try migrating from Travis to GitHub Actions for CI

* Update actions.yml and tests.yml

* Add ruby version

* Update config/database.yml.example

* Try rubocop and docker jobs

* Fix indentation

* Update tests.yml

* Update tests.yml

* Update gemfile

* Update rubocop job and Gemfile

* Update .rubocop_shopify_styleguide.yml

* Update gemfile

* Update .rubocop_todo.yml

* Update rubocop configuration and styleguides

* Fix rubocop offenses

* Update .rubocop.yml

* Update .rubocop.yml

* Udate .codeclimate.yml

* Update .codeclimate.yml

* Update .codeclimate.yml

* Update .codeclimate.yml

* Setup unit tests

* Update find_verified_user method in connection.rb

* Add yarn cache and install to setup

* install exporter dependencies; gdal/imagemagick

* Introduce Gitpod to migration work (#1538)

* Add CORS headers (#1536)

* Create .gitpod.dockerfile

* Create .gitpod.yml

* Create database.yml.gitpod

* Update .gitpod.yml

* ruby 2.4.6 in gitpod.dockerfile

* Update .gitpod.yml

* Update database.yml.gitpod

Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org>
Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>

* Install gdal and use egordm for yarn cache

* Delete unnecessary query and fix layout

* Run script with verbose output

* Try installing package in action.yml

* Setup controllers job

* Fix indentation

* Setup system tests job

* Setup docker development build job

* Fix identifiers

* Fix path to action.yml

* Update development dockerfile

* Setup docker production build job

* Update tests.yml

* Setup assets precompilation job

* Setup production environment

* Update tests.yml

* Update action.yml for production

* Try with test setup

* Remove action.yml for production

* Change names of jobs for friendliness and clarity

* Update .github/workflows/tests.yml

Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>

* Move dockerfiles to directory and change docker job names for clarity

* Update docker job names

Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org>
2021-09-20 18:50:31 -04:00

75 lines
1.9 KiB
Ruby

# Shadow Controller for the new front page
require 'will_paginate/array'
class FrontUiController < ApplicationController
protect_from_forgery except: :save_location
def index
@maps = Map.new_maps.first(4)
@unpaginated = true
# TODO: these could use optimization but are better than prev:
tag = Tag.where(name: 'featured').first
@mappers = if tag
User.where(login: tag.maps.collect(&:author))
else
[]
end
end
def all_maps
@maps = Map.new_maps
end
def nearby_mappers
return unless current_location.present?
lat = session[:lat]
lon = session[:lon]
@nearby_maps = Map.maps_nearby(lat: lat, lon: lon, dist: 10)
.page(params[:page])
.per_page(12)
@nearby_mappers = User.where(login: Map.maps_nearby(lat: lat, lon: lon, dist: 10)
.collect(&:author))
.paginate(page: params[:mappers], per_page: 12)
end
def save_location
lat = params[:lat].to_f
lon = params[:lon].to_f
session[:lat] = lat
session[:lon] = lon
head(200, content_type: "text/html")
end
def about
@map_count = Map.count
@img_count = Warpable.count
end
def location
@loc = params[:loc]
@maps = Map.page(params[:page])
.per_page(20)
.where('archived = ? and password = ? and location LIKE ?', false, '', "%#{@loc}%")
.order('updated_at DESC')
.group('maps.id')
respond_to do |format|
format.js
end
end
def gallery
@maps = Map.page(params[:page])
.per_page(20)
.where(archived: false, password: '')
.order('updated_at DESC')
.group('maps.id')
@authors = User.where(login: Map.featured.collect(&:author))
.paginate(page: params[:mappers], per_page: 20)
end
end