Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Vite #1370

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .browserslistrc

This file was deleted.

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ yarn-debug.log*
/yarn-error.log
yarn-debug.log*
.yarn-integrity

# Vite Ruby
/public/vite*
node_modules
# Vite uses dotenv and suggests to ignore local-only env files. See
# https://vitejs.dev/guide/env-and-mode.html#env-files
*.local

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[ruby]": {
"editor.defaultFormatter": "rebornix.ruby"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ gem "jbuilder"
gem "rails", "~> 7.1.0"
gem "rails_autolink"
gem "sass-rails"
gem "shakapacker"
gem "turbolinks"
gem "uglifier"

gem "vite_rails"
gem "view_component", "~> 2.82"

gem "pg"
Expand Down
50 changes: 18 additions & 32 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ GEM
ast (2.4.2)
autocorrect-rb (2.8.5-arm64-darwin)
rb_sys (>= 0.9.54)
autocorrect-rb (2.8.5-x86_64-linux)
rb_sys (>= 0.9.54)
autocorrect-rb (2.8.5-x86_64-linux-musl)
rb_sys (>= 0.9.54)
base64 (0.1.1)
bcrypt (3.1.19)
benchmark-ips (2.12.0)
Expand Down Expand Up @@ -158,6 +154,7 @@ GEM
railties (>= 3.2)
drb (2.1.1)
ruby2_keywords
dry-cli (1.0.0)
enumize (0.2.1)
rails (>= 5.0.0)
erubi (1.12.0)
Expand Down Expand Up @@ -277,8 +274,6 @@ GEM
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
notifications (1.1.0)
kaminari (>= 0.15)
rails (>= 5.2)
Expand Down Expand Up @@ -343,22 +338,22 @@ GEM
rexml (~> 3.2)
raabro (1.4.0)
racc (1.7.1)
rack (2.2.8)
rack (3.0.8)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (3.0.6)
rack
rack-proxy (0.7.7)
rack
rack-session (1.0.1)
rack (< 3)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.0)
rack (< 3)
webrick
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.0)
actioncable (= 7.1.0)
actionmailbox (= 7.1.0)
Expand Down Expand Up @@ -452,12 +447,6 @@ GEM
rucaptcha (3.2.1-arm64-darwin)
railties (>= 3.2)
rb_sys (>= 0.9.18)
rucaptcha (3.2.1-x86_64-linux)
railties (>= 3.2)
rb_sys (>= 0.9.18)
rucaptcha (3.2.1-x86_64-linux-musl)
railties (>= 3.2)
rb_sys (>= 0.9.18)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
Expand All @@ -471,12 +460,6 @@ GEM
second_level_cache (2.7.1)
activerecord (>= 6.0)
activesupport (>= 6.0)
semantic_range (3.0.0)
shakapacker (7.1.0)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
sidekiq (7.1.5)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
Expand Down Expand Up @@ -534,6 +517,13 @@ GEM
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
vite_rails (3.0.17)
railties (>= 5.1, < 8)
vite_ruby (~> 3.0, >= 3.2.2)
vite_ruby (3.3.4)
dry-cli (>= 0.7, < 2)
rack-proxy (~> 0.6, >= 0.6.1)
zeitwerk (~> 2.2)
warden (1.2.9)
rack (>= 2.0.9)
webrick (1.8.1)
Expand All @@ -543,11 +533,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-linux
x86_64-linux-musl

DEPENDENCIES
action-store
Expand Down Expand Up @@ -609,7 +595,6 @@ DEPENDENCIES
rucaptcha
sass-rails
second_level_cache
shakapacker
sidekiq (< 8)
sidekiq-cron
social-share-button
Expand All @@ -619,6 +604,7 @@ DEPENDENCIES
twemoji
uglifier
view_component (~> 2.82)
vite_rails

BUNDLED WITH
2.4.15
2.4.19
3 changes: 3 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

vite: bin/vite dev
web: bin/rails s
1 change: 0 additions & 1 deletion app/javascript/admin.scss

This file was deleted.

6 changes: 3 additions & 3 deletions app/javascript/admin/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "homeland/application.tailwind";
@import "~homeland/index";
@import "~homeland/dark-mode";
@import "~/homeland/application.tailwind";
@import "~/homeland/index";
@import "~/homeland/dark-mode";

body,
p,
Expand Down
3 changes: 0 additions & 3 deletions app/javascript/application.js

This file was deleted.

1 change: 1 addition & 0 deletions app/javascript/entrypoints/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "~/admin/index.scss";
3 changes: 3 additions & 0 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "~/front/index";
import "~/homeland/index";
import "~/vendor/bootstrap";
2 changes: 2 additions & 0 deletions app/javascript/entrypoints/front.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "~/front/index.scss";
@import "~/homeland/application.tailwind";
1 change: 1 addition & 0 deletions app/javascript/entrypoints/turbolinks-app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "~/homeland/turbolinks-app";
2 changes: 0 additions & 2 deletions app/javascript/front.scss

This file was deleted.

7 changes: 1 addition & 6 deletions app/javascript/front/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import i18n from "homeland/i18n";

require("./emoji-modal");
require("./notifier");
import i18n from "~/homeland/i18n";

const AppView = Backbone.View.extend({
el: "body",
Expand Down Expand Up @@ -37,8 +34,6 @@ const AppView = Backbone.View.extend({
},

initComponents() {
$("abbr.timeago").timeago();

// Bind Ctrl+Enter for submit
$(".cell_comments_new textarea").unbind("keydown");
$(".cell_comments_new textarea").bind(
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/front/home.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~homeland/_vars";
@import "~/homeland/_vars";

#home_index {
line-height: 160%;
Expand Down
11 changes: 6 additions & 5 deletions app/javascript/front/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require("./app");
require("./topics");
require("./toc");
require("./notifier");
require("./editor");
import("./emoji-modal");
import("./notifier");
import("./app");
import("./topics");
import("./toc");
import("./editor");
11 changes: 5 additions & 6 deletions app/javascript/front/index.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@import "~homeland/index";
@import "~/homeland/index.scss";

@import "~vendor/atwho";
@import "~vendor/jquery.fluidbox";
@import "~vendor/tooltipster.bundle";
@import "~vendor/social-share-button/index";
@import "~/vendor/atwho";
@import "~/vendor/tooltipster.bundle";
@import "~/vendor/social-share-button/index";

@import "notifications";
@import "home";
Expand All @@ -13,7 +12,7 @@
@import "search";
@import "toc";
@import "highlight";
@import "~homeland/dark-mode";
@import "~/homeland/dark-mode";

.page-topics {
.navbar-fixed-active {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/front/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Notifier {
}
}
} else {
return console.log(
return console.warn(
"Desktop notifications are not supported for this Browser/OS version yet."
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/front/search.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "~homeland/_vars";
@import "~/homeland/_vars";

.search-results {
.pagination {
margin-top: 25px;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/front/teams.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~homeland/_vars";
@import "~/homeland/_vars";

.team-header {
background: var(--sub-navbar-background-color);
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/front/toc.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~homeland/_vars";
@import "~/homeland/_vars";

.toc-container {
display: none;
Expand Down
35 changes: 3 additions & 32 deletions app/javascript/front/topics.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18n from "homeland/i18n";
import i18n from "~/homeland/i18n";

// TopicsController
window.Topics = {
window.Topics = window.Topics || {
topic_id: null,
user_liked_reply_ids: [],
};
Expand All @@ -28,7 +28,6 @@ window.TopicView = Backbone.View.extend({

this.initComponents();
this.initCableUpdate();
this.initContentImageZoom();
this.checkRepliesLikeStatus();
return this.itemsUpdated();
},
Expand Down Expand Up @@ -126,35 +125,6 @@ window.TopicView = Backbone.View.extend({
return this.unsetReplyTo();
},

initContentImageZoom() {
const exceptClasses = ["emoji", "twemoji", "media-object avatar-16"];
const imgEls = $(".markdown img");
for (let el of Array.from(imgEls)) {
if (exceptClasses.indexOf($(el).attr("class")) === -1) {
$(el).wrap(
`<a href='${$(el).attr(
"src"
)}' class='zoom-image' data-action='zoom'></a>`
);
}
}

// Bind click event
if (App.turbolinks || App.mobile) {
$("a.zoom-image").attr("target", "_blank");
} else {
$("a.zoom-image").fluidbox({
closeTrigger: [
{
selector: "window",
event: "scroll",
},
],
});
}
return true;
},

preview(body) {
$("#preview").text("Loading...");

Expand All @@ -174,6 +144,7 @@ window.TopicView = Backbone.View.extend({
preview_box.hide();

return $(".preview", switcher).click((e) => {
debugger;
e.preventDefault();
const target = e.currentTarget;

Expand Down
3 changes: 2 additions & 1 deletion app/javascript/front/users.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "~homeland/_vars";
@import "~/homeland/_vars";

.subnav {
margin-bottom: -18px;
.nav-tabs {
Expand Down
1 change: 0 additions & 1 deletion app/javascript/homeland/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $yellow: #dbc12d;
--filter-color: #808080;
--filter-active-color: #202020;

// speical vars
--btn-border-radius: 0.375rem;
--btn-box-shaodw: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--btn-secondary-text-color: rgba(55, 65, 81, 1);
Expand Down
Loading