Skip to content

Commit

Permalink
refactor: create gems for translations and base theme
Browse files Browse the repository at this point in the history
  • Loading branch information
kjellberg committed Jun 7, 2024
1 parent db0f018 commit 80c15c2
Show file tree
Hide file tree
Showing 176 changed files with 2,523 additions and 5 deletions.
11 changes: 7 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
inherit_gem:
standard: config/base.yml
AllCops:
SuggestExtensions: false
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ gem "bootsnap", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

gem "kiqr", path: "gems/kiqr"
gem "kiqr-translations", path: "gems/kiqr-translations"

gem "dry-initializer", "~> 3.1"
gem "meta-tags", "~> 2.20"
gem "simple_form", "~> 5.3.0"
gem "view_component", "~> 3.11"
gem "view_component-contrib", "~> 0.2.2"
gem "kiqr", path: "gems/kiqr"

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
Expand Down
20 changes: 20 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
PATH
remote: gems/kiqr-translations
specs:
kiqr-translations (0.1.0)

PATH
remote: gems/kiqr
specs:
Expand Down Expand Up @@ -315,9 +320,22 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-next-core (1.0.3)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
Expand Down Expand Up @@ -429,11 +447,13 @@ DEPENDENCIES
importmap-rails
jbuilder
kiqr!
kiqr-translations!
letter_opener_web (~> 2.0)
meta-tags (~> 2.20)
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.2)
rails-controller-testing
rubocop-rails-omakase
selenium-webdriver
simple_form (~> 5.3.0)
simplecov
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions gems/kiqr-themes-base/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
59 changes: 59 additions & 0 deletions gems/kiqr-themes-base/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
pull_request:
push:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true

- name: Lint code for consistent style
run: bin/rubocop -f github

test:
runs-on: ubuntu-latest

# services:
# redis:
# image: redis
# ports:
# - 6379:6379
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libsqlite3-0 libvips libsqlite3-0

- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true

- name: Run tests
env:
RAILS_ENV: test
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare test

- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/screenshots
if-no-files-found: ignore

10 changes: 10 additions & 0 deletions gems/kiqr-themes-base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.bundle/
/doc/
/log/*.log
/pkg/
/tmp/
/test/dummy/db/*.sqlite3
/test/dummy/db/*.sqlite3-*
/test/dummy/log/*.log
/test/dummy/storage/
/test/dummy/tmp/
8 changes: 8 additions & 0 deletions gems/kiqr-themes-base/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }

# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
16 changes: 16 additions & 0 deletions gems/kiqr-themes-base/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source "https://rubygems.org"

# Specify your gem's dependencies in kiqr-themes-base.gemspec.
gemspec

gem "puma"

gem "sqlite3"

gem "sprockets-rails"

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"
20 changes: 20 additions & 0 deletions gems/kiqr-themes-base/MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright Rasmus Kjellberg

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions gems/kiqr-themes-base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Kiqr::Themes::Base
Short description and motivation.

## Usage
How to use my plugin.

## Installation
Add this line to your application's Gemfile:

```ruby
gem "kiqr-themes-base"
```

And then execute:
```bash
$ bundle
```

Or install it yourself as:
```bash
$ gem install kiqr-themes-base
```

## Contributing
Contribution directions go here.

## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
8 changes: 8 additions & 0 deletions gems/kiqr-themes-base/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "bundler/setup"

APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"

load "rails/tasks/statistics.rake"

require "bundler/gem_tasks"
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions gems/kiqr-themes-base/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/kiqr/themes/base/engine", __dir__)
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
8 changes: 8 additions & 0 deletions gems/kiqr-themes-base/bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"

# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))

load Gem.bin_path("rubocop", "rubocop")
2 changes: 2 additions & 0 deletions gems/kiqr-themes-base/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rails.application.routes.draw do
end
20 changes: 20 additions & 0 deletions gems/kiqr-themes-base/kiqr-themes-base.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative "lib/kiqr/themes/base/version"

Gem::Specification.new do |spec|
spec.name = "kiqr-themes-base"
spec.version = Kiqr::Themes::Base::VERSION
spec.authors = ["Rasmus Kjellberg"]
spec.email = ["[email protected]"]
spec.homepage = "https://kiqr.dev"
spec.summary = "Base theme files for KIQR"
spec.description = "Views and assets for KIQR themes."
spec.license = "MIT"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/kiqr/kiqr-themes-base"
spec.metadata["changelog_uri"] = "https://github.com/kiqr/kiqr-themes-base"

spec.files = Dir.chdir(File.expand_path(__dir__)) do
Dir["{app,config,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
end
end
10 changes: 10 additions & 0 deletions gems/kiqr-themes-base/lib/kiqr/themes/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "kiqr/themes/base/version"
require "kiqr/themes/base/engine"

module Kiqr
module Themes
module Base
# Your code goes here...
end
end
end
8 changes: 8 additions & 0 deletions gems/kiqr-themes-base/lib/kiqr/themes/base/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Kiqr
module Themes
module Base
class Engine < ::Rails::Engine
end
end
end
end
7 changes: 7 additions & 0 deletions gems/kiqr-themes-base/lib/kiqr/themes/base/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Kiqr
module Themes
module Base
VERSION = "0.1.0"
end
end
end
Empty file.
6 changes: 6 additions & 0 deletions gems/kiqr-themes-base/test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"

Rails.application.load_tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
7 changes: 7 additions & 0 deletions gems/kiqr-themes-base/test/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
Empty file.
Loading

0 comments on commit 80c15c2

Please sign in to comment.