### Install Project Dependencies Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/README.md Navigate to the project directory and install all necessary Node.js dependencies using npm. This step is crucial before running any project commands. ```bash cd my-project npm install ``` -------------------------------- ### Start Local Development Server Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/README.md Run the development server to preview your HTML emails locally. This command typically starts a watch process that rebuilds emails on changes. ```bash npm run dev ``` -------------------------------- ### Docker Development Setup (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Provides commands for setting up and managing the development environment using Docker Compose. It covers initial setup (building images, setting up the database), starting all services, running tests, accessing the Rails console, managing background jobs, and resetting the database. ```bash # Initial setup docker compose build docker compose run web bin/rake db:setup # Start all services docker compose up # - Web: http://localhost:3000 # - Mailcatcher: http://localhost:1080 # - Elasticsearch: http://localhost:9200 # - Redis: localhost:6379 # Run tests docker compose run web bin/guard # Rails console docker compose run web bin/rails console # Run background jobs docker compose run web bundle exec sidekiq # Reset database docker compose run web bin/rake db:drop db:create db:migrate db:seed ``` -------------------------------- ### Clone Maizzle Starter Project Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/README.md Use npx to clone the Maizzle starter project from GitHub to your local machine. This command downloads the starter template into a specified directory. ```bash npx degit maizzle/maizzle my-project ``` -------------------------------- ### Build Emails for Production Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/README.md Generate optimized HTML emails for deployment. This command processes your email templates and assets into production-ready files. ```bash npm run build ``` -------------------------------- ### Devise User Authentication (Ruby) Source: https://context7.com/openaustralia/planningalerts/llms.txt Implements user registration, login, and email confirmation using the Devise gem. It includes examples for registering a new user, handling email confirmation, logging in, and accessing the current user and authentication status within controllers. Password confirmation is required during registration. ```ruby # Register new user # POST /users { user: { email: "user@example.com", password: "secure_password", password_confirmation: "secure_password" } } # Requires email confirmation user = User.find_by(email: "user@example.com") user.confirmed_at # => nil until confirmed # Login # POST /users/sign_in { user: { email: "user@example.com", password: "secure_password" } } # Current user in controllers current_user # => User object user_signed_in? # => true/false authenticate_user! # Before action to require login ``` -------------------------------- ### Application Model: Create, Update, and Query Source: https://context7.com/openaustralia/planningalerts/llms.txt Illustrates the usage of the Application model in Ruby. Includes creating/updating applications from scraper data, querying nearby applications using PostGIS, and performing searches with Searchkick. It assumes the presence of `Authority` and `Application` models and `RGeo` gem for geospatial queries. ```ruby # Import application from scraper data CreateOrUpdateApplicationService.call( authority: Authority.find_by(short_name: "bellingen"), council_reference: "DA2023/001", attributes: { address: "123 Main Street, Bellingen NSW 2454", description: "Alterations and additions to existing dwelling", info_url: "https://eservices.bellingen.nsw.gov.au/Pages/XC.Track/SearchApplication.aspx?id=DA2023/001", date_received: Date.parse("2023-12-01"), date_scraped: Time.zone.now, on_notice_from: Date.parse("2023-12-05"), on_notice_to: Date.parse("2023-12-19") } ) # Find nearby applications using PostGIS app = Application.find(12345) point = RGeo::Geographic.spherical_factory.point(app.lng, app.lat) nearby = Application.where("ST_DWithin(lonlat, ?, ?)", point.to_s, 2000) .where.not(id: app.id) .order(first_date_scraped: :desc) # Search applications with Searchkick results = Application.search( "swimming pool", where: { state: "NSW", first_date_scraped: { gte: 30.days.ago } }, fields: [:description, :address], limit: 20 ) ``` -------------------------------- ### Capistrano Deployment (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Illustrates commands for deploying the application to production and staging environments using Capistrano. It includes instructions for deploying the main branch to production, deploying a specific branch to staging, restarting the Puma web server, and viewing server logs. ```bash # Deploy to production bundle exec cap production deploy # Deploy specific branch to staging bundle exec cap staging --set branch=feature-branch deploy # Restart puma bundle exec cap production puma:restart # View logs bundle exec cap production puma:logs ``` -------------------------------- ### Bulk API - All applications (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Access all planning applications with pagination for data synchronization. Requires a bulk API key. Use the `since_id` parameter to fetch subsequent batches of data. The response includes the `max_id` for the next request. ```bash # Get first batch of applications curl "https://www.planningalerts.org.au/applications.json?key=YOUR_BULK_API_KEY" # Continue from last ID for pagination curl "https://www.planningalerts.org.au/applications.json?since_id=12345&key=YOUR_BULK_API_KEY" # Response includes max_id for next request # { # "max_id": 13345, # "applications": [ # {...}, # {...} # ] # } # Keep paginating until no more results # Next request: since_id=13345 ``` -------------------------------- ### Query applications by scrape date (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve all planning applications that were collected from council websites on a specific date. This requires bulk API access and a specific bulk API key. The response includes a description of the date and application count. ```bash # Get applications scraped on a specific date (requires bulk API access) curl "https://www.planningalerts.org.au/applications.json?date_scraped=2023-12-15&key=YOUR_BULK_API_KEY" ``` -------------------------------- ### Query applications by authority (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve all recent planning applications for a specific local government authority using a cURL command. Requires an API key. The response includes application count, max ID, page count, and a list of applications with their details. ```bash # Get applications for Bellingen Shire Council curl "https://www.planningalerts.org.au/authorities/bellingen/applications.json?key=YOUR_API_KEY" ``` -------------------------------- ### Bulk API - All applications Source: https://context7.com/openaustralia/planningalerts/llms.txt Access all planning applications using pagination for data synchronization. Requires a bulk API key. ```APIDOC ## GET /applications.json ### Description Access all planning applications with pagination for data synchronization. This endpoint requires a bulk API key. ### Method GET ### Endpoint `/applications.json` ### Query Parameters - **since_id** (integer) - Optional - Retrieve applications with an ID greater than this value. Used for incremental updates. - **key** (string) - Required - Your bulk API key. ### Response #### Success Response (200) - **max_id** (integer) - The highest application ID in the current response batch. Use this for the `since_id` parameter in subsequent requests. - **applications** (array) - An array of application objects (structure similar to applications by authority endpoint). ### Request Example ```bash # Get first batch of applications curl "https://www.planningalerts.org.au/applications.json?key=YOUR_BULK_API_KEY" # Continue from last ID for pagination curl "https://www.planningalerts.org.au/applications.json?since_id=12345&key=YOUR_BULK_API_KEY" ``` ### Response Example ```json { "max_id": 13345, "applications": [ {...}, {...} ] } # Keep paginating until no more results # Next request: since_id=13345 ``` ``` -------------------------------- ### Query applications by area (Bounding Box) (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve planning applications within a rectangular geographic area defined by bottom-left and top-right coordinates. Supports pagination for large result sets. An API key is required. ```bash # Define area by bottom-left and top-right coordinates curl "https://www.planningalerts.org.au/applications.json?bottom_left_lat=-33.9&bottom_left_lng=151.1&top_right_lat=-33.8&top_right_lng=151.3&key=YOUR_API_KEY" # Pagination for large result sets curl "https://www.planningalerts.org.au/applications.json?bottom_left_lat=-33.9&bottom_left_lng=151.1&top_right_lat=-33.8&top_right_lng=151.3&page=2&count=50&key=YOUR_API_KEY" ``` -------------------------------- ### ApplicationsController - Web Interface - Ruby Source: https://context7.com/openaustralia/planningalerts/llms.txt Provides a web interface for browsing and searching planning applications. It supports searching by address, displaying paginated results with a map, showing individual application details, and full-text search using Searchkick/Elasticsearch. ```ruby # Search by address (root page) # GET /applications/address?address=24+Bruce+Road+Glenbrook # Geocodes address and redirects to point search # Search results page # GET /applications?lat=-33.7677&lng=150.6242&radius=2000 # Shows paginated results with map # Individual application page # GET /applications/12345 # Shows full details, comments, nearby applications # Trending applications # GET /applications/trending # Applications with most comments in last 6 months # Full-text search # GET /applications/search?q=swimming+pool # Uses Searchkick/Elasticsearch ``` -------------------------------- ### Query applications by scrape date Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve applications that were collected from council websites on a specific date. Requires a bulk API key. ```APIDOC ## GET /applications.json ### Description Retrieve all applications that were collected from council websites on a specific date. This endpoint typically requires bulk API access. ### Method GET ### Endpoint `/applications.json` ### Query Parameters - **date_scraped** (string) - Required - The date in YYYY-MM-DD format. - **key** (string) - Required - Your bulk API key. ### Response #### Success Response (200) - **description** (string) - A description of the results, indicating the scrape date. - **application_count** (integer) - The total number of applications found for that date. - **applications** (array) - An array of application objects (structure similar to applications by authority endpoint). ### Request Example ```bash curl "https://www.planningalerts.org.au/applications.json?date_scraped=2023-12-15&key=YOUR_BULK_API_KEY" ``` ### Response Example ```json { "description": "All applications collected on 2023-12-15", "application_count": 243, "applications": [...] } ``` ``` -------------------------------- ### Fetch Planning Applications in RSS or GeoJSON Source: https://context7.com/openaustralia/planningalerts/llms.txt Demonstrates how to retrieve planning application data from the API using cURL. Supports RSS for general feeds and GeoJSON for mapping purposes. Requires an API key for access. ```bash # RSS feed for any query curl "https://www.planningalerts.org.au/applications.rss?suburb=Newtown&state=NSW&key=YOUR_API_KEY" # GeoJSON for mapping applications curl "https://www.planningalerts.org.au/applications.geojson?lat=-33.8688&lng=151.2093&radius=2000&key=YOUR_API_KEY" ``` -------------------------------- ### Render Planning Alert Details (Markdown) Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/application.html Demonstrates how planning alert details are formatted using markdown. It includes links for the address, distance, and description, as well as embedded map images. Assumes templating variables like {{{ address }}} are pre-processed. ```markdown [{{{ address }}}]( {{{ url }}} ) ------------------------------ [{{{ distance }}}]( {{{ url }}} ) [{{{ description }}}]( {{{ url }}} ) [![Map of {{{ address }}}]( {{{ map }}} )]( {{{ url }}} ) [![Map of {{{ address }}}]( {{{ map }}} )]( {{{ url }}} ) [{{{ address }}}]( {{{ url }}} ) ------------------------------ [{{{ description }}}]( {{{ url }}} ) ``` -------------------------------- ### Environment Configuration (.env and Rails Credentials) Source: https://context7.com/openaustralia/planningalerts/llms.txt Details essential environment variables and credentials for the application. It lists key variables for development (`.env`) such as API keys for Google Maps, Mappify, Morph.io, and connection URLs for Elasticsearch and Redis. It also covers accessing encrypted Rails credentials. ```dotenv # .env.development GOOGLE_MAPS_API_KEY=your_google_key MAPPIFY_API_KEY=your_mappify_key MORPH_API_KEY=your_morph_key ELASTICSEARCH_URL=http://localhost:9200 REDIS_URL=redis://localhost:6379 # Rails credentials (encrypted) # Edit with: EDITOR=vim rails credentials:edit google_maps: server_key: your_server_key client_key: your_client_key mappify_api_key: your_mappify_key # Access in code Rails.application.credentials.dig(:google_maps, :server_key) ``` -------------------------------- ### Query applications by location (Point Radius) (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Find planning applications within a specified radius of a geographic point. Supports latitude, longitude, radius, and address geocoding. An API key is required. The response may include distance context. ```bash # Find applications within 2000 meters of coordinates curl "https://www.planningalerts.org.au/applications.json?lat=-33.8688&lng=151.2093&radius=2000&key=YOUR_API_KEY" # With address geocoding curl "https://www.planningalerts.org.au/applications.json?address=24%20Bruce%20Road%20Glenbrook%20NSW%202773&radius=800&key=YOUR_API_KEY" # Specify custom radius (200m for street level) curl "https://www.planningalerts.org.au/applications.json?lat=-33.8688&lng=151.2093&radius=200&key=YOUR_API_KEY" ``` -------------------------------- ### Query applications by suburb or postcode (Bash) Source: https://context7.com/openaustralia/planningalerts/llms.txt Filter planning applications by suburb, state, or postcode. Multiple filters can be combined for more specific queries. An API key is required. ```bash # By suburb curl "https://www.planningalerts.org.au/applications.json?suburb=Marrickville&key=YOUR_API_KEY" # By suburb and state curl "https://www.planningalerts.org.au/applications.json?suburb=Richmond&state=VIC&key=YOUR_API_KEY" # By postcode curl "https://www.planningalerts.org.au/applications.json?postcode=2000&key=YOUR_API_KEY" # Combined filters curl "https://www.planningalerts.org.au/applications.json?suburb=Newtown&state=NSW&postcode=2042&key=YOUR_API_KEY" ``` -------------------------------- ### Admin Namespace - Administrative Interface - Ruby Source: https://context7.com/openaustralia/planningalerts/llms.txt Provides a comprehensive administrative interface using Administrate for platform management. It includes sections for managing authorities, comments, API usage, API keys, background jobs, feature flags, and A/B testing. ```ruby # Admin dashboard # GET /admin # Requires user with :admin role # Manage authorities # GET /admin/authorities # PATCH /admin/authorities/123 # POST /admin/authorities/123/import # Trigger scraper # Manage comments # GET /admin/comments # POST /admin/comments/456/confirm # Publish comment # POST /admin/comments/456/resend # Resend to council # View API usage # GET /admin/api_usages # Track API key usage and rate limits # Manage API keys # GET /admin/api_keys # PATCH /admin/api_keys/789 # Background jobs monitoring # GET /admin/jobs # Sidekiq web interface for job management # Feature flags # GET /admin/flipper # Enable/disable features with Flipper # A/B testing # GET /admin/split # View A/B test results ``` -------------------------------- ### API Key Authentication and Rate Limiting (Ruby) Source: https://context7.com/openaustralia/planningalerts/llms.txt Provides token-based authentication for API access, including rate limiting. It shows how to create API keys with an expiration date and how to use them in API requests. The system includes a mechanism to find and validate keys, with rate limiting enforced by `rack-attack` based on API key and IP address. ```ruby # Create API key api_key = ApiKey.create!( user: user, name: "My App", bulk: false, # Standard API access expires_at: 1.year.from_now ) # Use in API requests # ?key=YOUR_API_KEY # Find and validate key ApiKey.find_valid(params[:key]) # Returns nil if expired or disabled # Rate limiting via rack-attack # Configured in config/initializers/rack_attack.rb # Throttles based on API key and IP address ``` -------------------------------- ### ApplicationsController Source: https://context7.com/openaustralia/planningalerts/llms.txt API endpoints for browsing and searching planning applications through the web interface. ```APIDOC ## Applications API ### Description Endpoints for accessing and searching planning applications. ### Method GET ### Endpoint `/applications` ### Query Parameters - **lat** (Float) - Optional - Latitude for location-based search. - **lng** (Float) - Optional - Longitude for location-based search. - **radius** (Integer) - Optional - Radius in meters for location-based search. - **q** (String) - Optional - Full-text search query. ### Request Example ```http # Search by coordinates and radius GET /applications?lat=-33.7677&lng=150.6242&radius=2000 # Full-text search GET /applications/search?q=swimming+pool ``` ### Response #### Success Response (200) - **applications** (Array) - Paginated list of application objects. - **pagination** (Object) - Pagination details. #### Response Example ```json { "applications": [ { "id": 12345, "title": "Proposed Development", "address": "123 Main St, Sydney NSW", "status": "Under Assessment" } ], "pagination": { "current_page": 1, "total_pages": 10 } } ``` ## Individual Application ### Description Retrieve details for a specific planning application. ### Method GET ### Endpoint `/applications/{id}` ### Path Parameters - **id** (Integer) - Required - The unique identifier of the application. ### Response #### Success Response (200) - **application** (Object) - Detailed application object including comments and nearby applications. #### Response Example ```json { "application": { "id": 12345, "title": "Proposed Development", "address": "123 Main St, Sydney NSW", "description": "Detailed description of the proposal.", "comments": [...], "nearby_applications": [...] } } ``` ## Trending Applications ### Description Retrieve applications with the most comments in the last 6 months. ### Method GET ### Endpoint `/applications/trending ### Response #### Success Response (200) - **applications** (Array) - List of trending application objects. #### Response Example ```json { "applications": [ { "id": 67890, "title": "Community Centre", "comment_count": 55 } ] } ``` ## Search by Address (Root Page Redirect) ### Description Geocodes an address provided in the query parameter and redirects to the point search results page. ### Method GET ### Endpoint `/applications/address` ### Query Parameters - **address** (String) - Required - The address to geocode. ### Request Example ```http GET /applications/address?address=24+Bruce+Road+Glenbrook ``` ``` -------------------------------- ### Export Default Module Configuration (JavaScript) Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/v-fill.html Exports a JavaScript module with default configuration settings for width and image. The values can be overridden by 'props'. If 'props.width' is not provided, it defaults to '600px'. If 'props.image' is not provided, it defaults to a placeholder image URL. This is commonly used in front-end frameworks for component configuration. ```javascript module.exports = { width: props.width || '600px', image: props.image || 'https://via.placeholder.com/600x400' } ``` -------------------------------- ### Authority Model: Council Data and Coverage Statistics Source: https://context7.com/openaustralia/planningalerts/llms.txt Shows how to use the Authority model in Ruby to interact with local government council data. Includes finding authorities, checking scraper status, retrieving statistics on new applications and comments, and calculating population coverage. Assumes `Authority` model and `ImportApplicationsService` are defined. ```ruby # Find an authority authority = Authority.find_short_name_encoded!("blue-mountains") # Check scraper status authority.covered? # => true if morph_name present authority.morph_name # => "planningalerts-scrapers/blue_mountains" # Get statistics authority.median_new_applications_per_week # => 12 authority.new_applications_per_week # => [[Date, count], ...] authority.comments_per_week # => [[Date, count], ...] # Population coverage Authority.total_population_2021_covered_by_all_active_authorities # => 21500000 Authority.percentage_population_covered_by_all_active_authorities # => 84.6 # Import applications for an authority ImportApplicationsService.call( authority: authority, logger: Rails.logger, scrape_delay: 28, # days to look back morph_api_key: ENV['MORPH_API_KEY'] ) ``` -------------------------------- ### Retrieve Applications (RSS/GeoJSON) Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve planning applications using various query parameters and specify the output format as RSS or GeoJSON. ```APIDOC ## GET /applications ### Description Retrieve planning applications based on specified criteria. Supports RSS and GeoJSON output formats. ### Method GET ### Endpoint `/applications.rss` or `/applications.geojson` ### Parameters #### Query Parameters - **suburb** (string) - Optional - The suburb to filter applications by. - **state** (string) - Optional - The state to filter applications by. - **lat** (number) - Optional - The latitude for geographical searches. - **lng** (number) - Optional - The longitude for geographical searches. - **radius** (integer) - Optional - The radius in meters for geographical searches. - **key** (string) - Required - Your API key. ### Request Example ```bash # RSS feed for any query curl "https://www.planningalerts.org.au/applications.rss?suburb=Newtown&state=NSW&key=YOUR_API_KEY" # GeoJSON for mapping applications curl "https://www.planningalerts.org.au/applications.geojson?lat=-33.8688&lng=151.2093&radius=2000&key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **(GeoJSON)**: ```json { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [151.2093, -33.8688] }, "properties": { "id": 12345, "council_reference": "DA2023/001", "address": "123 Main St", "description": "New dwelling" } } ] } ``` - **(RSS)**: (Standard RSS feed structure containing application details) ``` -------------------------------- ### Import Planning Applications (Ruby) Source: https://context7.com/openaustralia/planningalerts/llms.txt A scheduled Sidekiq job that imports planning applications from Morph.io scrapers. It runs daily for each active authority, utilizing an API key for access. The job requires an authority ID as input and logs to Rails logger. ```ruby # Triggered by sidekiq-cron schedule # Runs daily for each active authority ImportApplicationsJob.perform_async(authority_id) # Job implementation class ImportApplicationsJob include Sidekiq::Job def perform(authority_id) authority = Authority.find(authority_id) ImportApplicationsService.call( authority: authority, logger: Rails.logger, scrape_delay: 28, morph_api_key: ENV['MORPH_API_KEY'] ) end end # Configure in initializers/sidekiq_cron.yml # schedule: "0 2 * * *" # 2 AM daily ``` -------------------------------- ### JavaScript Module Exports for Alignment and Microsoft Office Styling Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/button/secondary.html This JavaScript snippet exports an object used for configuring component styles. It includes utility classes for text alignment (left, center, right) based on props, and sets default values for Microsoft Office specific properties like msoPt, msoPr, msoPb, and msoPl. These are intended for email rendering or specific document formats. ```javascript module.exports = { align: { left: 'text-left', center: 'text-center', right: 'text-right' }[props.align], href: props.href, msoPt: props['mso-pt'] || '16px', msoPr: props['mso-pr'] || '32px', msoPb: props['mso-pb'] || '30px', msoPl: props['mso-pl'] || '32px' } ``` -------------------------------- ### Query applications by authority Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve all recent planning applications submitted to a specific local government authority. Requires an API key. ```APIDOC ## GET /authorities/{authority_slug}/applications.json ### Description Get all recent planning applications for a specific local government authority. ### Method GET ### Endpoint `/authorities/{authority_slug}/applications.json` ### Query Parameters - **key** (string) - Required - Your API key. ### Response #### Success Response (200) - **application_count** (integer) - The total number of applications found. - **max_id** (integer) - The highest application ID within the results. - **page_count** (integer) - The total number of pages available for the results. - **applications** (array) - An array of application objects. - **id** (integer) - Unique identifier for the application. - **council_reference** (string) - The reference number assigned by the council. - **address** (string) - The street address of the application. - **description** (string) - A brief description of the proposed development. - **info_url** (string) - A URL to the application details on the council's website. - **date_scraped** (string) - The date the application data was scraped. - **date_received** (string) - The date the application was received by the council. - **lat** (number) - The latitude of the application location. - **lng** (number) - The longitude of the application location. - **authority** (object) - Information about the authority that processed the application. - **full_name** (string) - The full name of the local government authority. ### Request Example ```bash curl "https://www.planningalerts.org.au/authorities/bellingen/applications.json?key=YOUR_API_KEY" ``` ### Response Example ```json { "application_count": 42, "max_id": 12345, "page_count": 1, "applications": [ { "id": 12345, "council_reference": "DA2023/001", "address": "123 Main Street, Bellingen NSW 2454", "description": "Alterations and additions to existing dwelling", "info_url": "https://council.example.com/da/12345", "date_scraped": "2023-12-15", "date_received": "2023-12-01", "lat": -30.4519, "lng": 152.8969, "authority": { "full_name": "Bellingen Shire Council" } } ] } ``` ``` -------------------------------- ### Query applications by location (point radius) Source: https://context7.com/openaustralia/planningalerts/llms.txt Find planning applications within a specified radius of a geographic point (latitude and longitude) or an address. Requires an API key. ```APIDOC ## GET /applications.json ### Description Find planning applications within a specified radius of a geographic point or an address. ### Method GET ### Endpoint `/applications.json` ### Query Parameters - **lat** (number) - Optional - The latitude of the center point. - **lng** (number) - Optional - The longitude of the center point. - **address** (string) - Optional - The address to geocode and search around. - **radius** (integer) - Optional - The search radius in meters. Defaults to 1000m. - **key** (string) - Required - Your API key. ### Response #### Success Response (200) - **application_count** (integer) - The number of applications found. - **description** (string) - A textual description of the search criteria. - **applications** (array) - An array of application objects (structure similar to applications by authority endpoint). ### Request Example ```bash # Find applications within 2000 meters of coordinates curl "https://www.planningalerts.org.au/applications.json?lat=-33.8688&lng=151.2093&radius=2000&key=YOUR_API_KEY" # With address geocoding curl "https://www.planningalerts.org.au/applications.json?address=24%20Bruce%20Road%20Glenbrook%20NSW%202773&radius=800&key=YOUR_API_KEY" # Specify custom radius (200m for street level) curl "https://www.planningalerts.org.au/applications.json?lat=-33.8688&lng=151.2093&radius=200&key=YOUR_API_KEY" ``` ### Response Example ```json { "application_count": 15, "description": "Recent applications within 2 km of 24 Bruce Road, Glenbrook NSW 2773", "applications": [...] } ``` ``` -------------------------------- ### Alert Model: Geographic Notifications and Management Source: https://context7.com/openaustralia/planningalerts/llms.txt Demonstrates the functionality of the Alert model in Ruby for setting up geographic notifications. It covers creating alerts, automatic geocoding of addresses, retrieving new applications and comments, defining radius sizes, and unsubscribing from alerts. Assumes `User` and `Alert` models are defined. ```ruby # Create a new alert for a user user = User.find_by(email: "user@example.com") alert = Alert.create!( user: user, address: "24 Bruce Road, Glenbrook NSW 2773", radius_meters: 800, # neighbourhood size unsubscribed: false ) # Alert automatically geocodes the address on save alert.lat # => -33.7677 alert.lng # => 150.6242 alert.location # => Location object # Find new applications for this alert new_apps = alert.recent_new_applications # Returns applications scraped since last alert was sent # Find applications with new comments apps_with_comments = alert.applications_with_new_comments # Returns applications in area with comments since last alert # Available radius sizes Alert::RADIUS_DESCRIPTIONS # => { 200 => "street", 800 => "neighbourhood", 2000 => "suburb" } # Unsubscribe an alert alert.unsubscribe! ``` -------------------------------- ### Markdown Template for Alert Header Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/comment.html A markdown template used to format the header of a planning alert, including the commenter's name and a link to their comment. ```markdown [{{{{ name }}}} commented:]({{{{ url }}}}) [””]({{{{ url }}}}) ``` -------------------------------- ### Application Model Services Source: https://context7.com/openaustralia/planningalerts/llms.txt Services for managing planning applications, including creation, updating, and searching. ```APIDOC ## Application Model Services ### Description Interact with the Application model for creating, updating, and querying planning application data. ### Methods #### Create or Update Application ```ruby # Import application from scraper data CreateOrUpdateApplicationService.call( authority: Authority.find_by(short_name: "bellingen"), council_reference: "DA2023/001", attributes: { address: "123 Main Street, Bellingen NSW 2454", description: "Alterations and additions to existing dwelling", info_url: "https://eservices.bellingen.nsw.gov.au/Pages/XC.Track/SearchApplication.aspx?id=DA2023/001", date_received: Date.parse("2023-12-01"), date_scraped: Time.zone.now, on_notice_from: Date.parse("2023-12-05"), on_notice_to: Date.parse("2023-12-19") } ) ``` #### Find Nearby Applications ```ruby # Find nearby applications using PostGIS app = Application.find(12345) point = RGeo::Geographic.spherical_factory.point(app.lng, app.lat) nearby = Application.where("ST_DWithin(lonlat, ?, ?)", point.to_s, 2000) .where.not(id: app.id) .order(first_date_scraped: :desc) ``` #### Search Applications ```ruby # Search applications with Searchkick results = Application.search( "swimming pool", where: { state: "NSW", first_date_scraped: { gte: 30.days.ago } }, fields: [:description, :address], limit: 20 ) ``` ``` -------------------------------- ### Query applications by suburb, state, or postcode Source: https://context7.com/openaustralia/planningalerts/llms.txt Filter planning applications by suburb, state, or postcode identifiers. Requires an API key. ```APIDOC ## GET /applications.json ### Description Filter applications by suburb, state, or postcode identifiers. ### Method GET ### Endpoint `/applications.json` ### Query Parameters - **suburb** (string) - Optional - The name of the suburb. - **state** (string) - Optional - The state abbreviation (e.g., NSW, VIC). - **postcode** (string) - Optional - The postcode. - **key** (string) - Required - Your API key. ### Request Example ```bash # By suburb curl "https://www.planningalerts.org.au/applications.json?suburb=Marrickville&key=YOUR_API_KEY" # By suburb and state curl "https://www.planningalerts.org.au/applications.json?suburb=Richmond&state=VIC&key=YOUR_API_KEY" # By postcode curl "https://www.planningalerts.org.au/applications.json?postcode=2000&key=YOUR_API_KEY" # Combined filters curl "https://www.planningalerts.org.au/applications.json?suburb=Newtown&state=NSW&postcode=2042&key=YOUR_API_KEY" ``` ``` -------------------------------- ### Query applications by area (bounding box) Source: https://context7.com/openaustralia/planningalerts/llms.txt Retrieve planning applications within a specified rectangular geographic area defined by bounding coordinates. Requires an API key. ```APIDOC ## GET /applications.json ### Description Retrieve all applications within a rectangular geographic area defined by corner coordinates. ### Method GET ### Endpoint `/applications.json` ### Query Parameters - **bottom_left_lat** (number) - Required - Latitude of the bottom-left corner of the bounding box. - **bottom_left_lng** (number) - Required - Longitude of the bottom-left corner of the bounding box. - **top_right_lat** (number) - Required - Latitude of the top-right corner of the bounding box. - **top_right_lng** (number) - Required - Longitude of the top-right corner of the bounding box. - **page** (integer) - Optional - Page number for pagination. Defaults to 1. - **count** (integer) - Optional - Number of results per page. Defaults to 25. - **key** (string) - Required - Your API key. ### Request Example ```bash # Define area by bottom-left and top-right coordinates curl "https://www.planningalerts.org.au/applications.json?bottom_left_lat=-33.9&bottom_left_lng=151.1&top_right_lat=-33.8&top_right_lng=151.3&key=YOUR_API_KEY" # Pagination for large result sets curl "https://www.planningalerts.org.au/applications.json?bottom_left_lat=-33.9&bottom_left_lng=151.1&top_right_lat=-33.8&top_right_lng=151.3&page=2&count=50&key=YOUR_API_KEY" ``` ``` -------------------------------- ### Admin Namespace Source: https://context7.com/openaustralia/planningalerts/llms.txt Endpoints for the administrative interface, built with Administrate, for managing the platform. ```APIDOC ## Admin Dashboard ### Description Access the main administrative dashboard. ### Method GET ### Endpoint `/admin` ### Notes - Requires a user with the `:admin` role. ## Manage Authorities ### Description View, update, and import authority data. ### Method GET, PATCH, POST ### Endpoint - `GET /admin/authorities` - `PATCH /admin/authorities/{id}` - `POST /admin/authorities/{id}/import` (Trigger scraper) ## Manage Comments (Admin) ### Description Admin interface for managing comments, including publishing and resending. ### Method GET, POST ### Endpoint - `GET /admin/comments` - `POST /admin/comments/{id}/confirm` (Publish comment) - `POST /admin/comments/{id}/resend` (Resend to council) ## View API Usage ### Description Monitor API key usage and rate limits. ### Method GET ### Endpoint `/admin/api_usages` ## Manage API Keys ### Description View and manage API keys for the platform. ### Method GET, PATCH ### Endpoint - `GET /admin/api_keys` - `PATCH /admin/api_keys/{id}` ## Background Jobs Monitoring ### Description Access the Sidekiq web interface for managing background jobs. ### Method GET ### Endpoint `/admin/jobs` ## Feature Flags ### Description Enable or disable platform features using Flipper. ### Method GET ### Endpoint `/admin/flipper` ## A/B Testing ### Description View results of A/B tests. ### Method GET ### Endpoint `/admin/split` ``` -------------------------------- ### Comment Model: User Feedback and Visibility Source: https://context7.com/openaustralia/planningalerts/llms.txt Details the usage of the Comment model in Ruby for handling user feedback on planning applications. Covers creating comments, publishing them, sending them to councils, querying visible comments, and checking comment visibility. Assumes `Application`, `User`, and `Comment` models are defined. ```ruby # Create a comment on an application app = Application.find_by(council_reference: "DA2023/001") user = User.find_by(email: "user@example.com") comment = Comment.create!( application: app, user: user, name: "Jane Smith", text: "I support this application as it improves the streetscape", address: "125 Main Street, Bellingen NSW 2454" ) # Publish and send to authority comment.update!(published: true, published_at: Time.zone.now) comment.send_comment! # Queues email to council # Query visible comments visible_comments = Comment.visible .where(application: app) .order(published_at: :desc) # Check comment visibility comment.visible? # => true (published and not hidden) ``` -------------------------------- ### ERB Account Activation Email Template Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/templates/activate_account_instructions.html This ERB template defines the structure and content of an account activation email. It includes a preheader, a main title, activation instructions, and an embedded image. The dynamic parts are handled by ERB variables and helpers. ```erb --- title: Activate account instructions preheader: "Thanks for getting onboard! (just confirming you're you)" bodyClass: bg-white dark-mode:bg-\[#333\] permalink: ../app/views/users/activation_mailer/notify.html.erb --- Thanks for getting onboard! =========================== Activate my account (just confirming you're you) ![](<%= attachments['illustration.png'].url %>) ``` -------------------------------- ### CommentsController Source: https://context7.com/openaustralia/planningalerts/llms.txt API endpoints for managing user comments on planning applications, including creation, reporting, and moderation. ```APIDOC ## Create Comment ### Description Submits a new comment on a specific planning application. ### Method POST ### Endpoint `/applications/{application_id}/comments` ### Path Parameters - **application_id** (Integer) - Required - The ID of the application to comment on. ### Request Body - **comment** (Object) - Required - **name** (String) - Required - The name of the commenter. - **text** (String) - Required - The content of the comment. - **address** (String) - Optional - The commenter's address. - **g-recaptcha-response** (String) - Required - reCAPTCHA verification token. ### Request Example ```json { "comment": { "name": "Jane Smith", "text": "I support this application", "address": "125 Main Street" }, "g-recaptcha-response": "token" } ``` ### Response #### Success Response (201) - **comment** (Object) - The created comment object. ## Preview Unpublished Comment ### Description Allows users to preview a draft comment before publishing. ### Method GET ### Endpoint `/applications/{application_id}/comments/new` ### Path Parameters - **application_id** (Integer) - Required - The ID of the application. ### Response #### Success Response (200) - **comment** (Object) - The draft comment object. ## Publish Comment ### Description Publishes a previously drafted or unpublished comment. ### Method POST ### Endpoint `/applications/{application_id}/comments/{comment_id}/publish` ### Path Parameters - **application_id** (Integer) - Required - The ID of the application. - **comment_id** (Integer) - Required - The ID of the comment to publish. ### Request Body - **publish_to** (String) - Required - Where to publish (`authority` or `application`). - **comment** (Object) - Required - **published** (Boolean) - Must be `true`. ### Request Example ```json { "publish_to": "authority", "comment": { "published": true } } ``` ## Report Comment ### Description Reports an inappropriate comment for review. ### Method POST ### Endpoint `/comments/{comment_id}/reports` ### Path Parameters - **comment_id** (Integer) - Required - The ID of the comment being reported. ### Request Body - **report** (Object) - Required - **name** (String) - Required - The name of the reporter. - **email** (String) - Required - The email of the reporter. - **details** (String) - Required - The reason for the report. ### Request Example ```json { "report": { "name": "Reporter Name", "email": "reporter@example.com", "details": "Reason for report" } } ``` ``` -------------------------------- ### Process Alert Emails Source: https://context7.com/openaustralia/planningalerts/llms.txt Background service for processing user alerts and sending notification emails. It handles individual alert processing and batch processing for all active alerts. ```APIDOC ## Process Alert Service ### Description Background service that processes user alerts and sends notification emails. It can process a single alert or all active alerts. ### Method Service Call (conceptual) ### Parameters #### Alert Processing - **alert** (Object) - Required - The alert object to process. ### Request Example ```ruby # Process a single alert alert = Alert.find(123) ProcessAlertService.call(alert: alert) # Process all active alerts Alert.active.find_each do |alert| ProcessAlertJob.perform_async(alert.id) end ``` ### Response #### Success Response - **emails_sent** (Integer) - Number of emails sent (0 or 1). - **app_count** (Integer) - Number of new applications included. - **comment_count** (Integer) - Number of new comments included. #### Response Example ```ruby [1, 0, 2] # emails_sent, app_count, comment_count ``` ### Notes - Sends email only if user email is confirmed, there are new applications/comments, and the alert is not unsubscribed. - Updates `alert.last_sent` and `alert.last_processed` timestamps. ``` -------------------------------- ### Markdown Template for Comment Date Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/comment.html A markdown template to display the date a comment was made on a planning alert, linked to the alert's URL. ```markdown [Comment made on:]({{{ url }}}) ``` -------------------------------- ### Ruby ERB Template for Comment Rendering Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/comment.html Renders comments from planning alerts using Ruby's ERB templating. It iterates through comment paragraphs and links them to the alert's URL. ```erb <% {{{ comment_as_paragraphs }}}.each do |p| %> [<%= p %>]({{{ url }}}) <% end %> ``` -------------------------------- ### Markdown Link with Icon Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/box-button.html Generates a Markdown link that includes an image (icon) followed by the link text, both pointing to a specified URL. This is used to visually represent alerts or locations. ```markdown [![{icon}}]({{{icon}}})({{{url}}}) ``` -------------------------------- ### Basic Markdown Link Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/box-button.html Generates a simple Markdown link pointing to a specified URL. This is used for navigation or referencing external resources. ```markdown []({{{url}}}) ``` -------------------------------- ### Export Default Module Configuration (JavaScript) Source: https://github.com/openaustralia/planningalerts/blob/main/maizzle/src/components/v-image.html This JavaScript code exports a module configuration object. It defines default values for 'width', 'height', and 'image' properties, using provided 'props' if available, otherwise falling back to predefined defaults. This is commonly used in Node.js environments for module exports. ```javascript module.exports = { width: props.width || '600px', height: props.height || '400px', image: props.image || 'https://via.placeholder.com/600x400' } ```