Skip to content

Commit

Permalink
Merge branch 'master' into text-position-error#4369
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored Feb 24, 2024
2 parents 27ebc5f + 45990f7 commit 7ff4782
Show file tree
Hide file tree
Showing 72 changed files with 2,382 additions and 1,781 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ version: 2
updates:
- package-ecosystem: npm
directory: "/"
groups:
minor-and-patch:
update-types:
- "minor"
- "patch"
schedule:
interval: daily
open-pull-requests-limit: 10
Expand All @@ -10,6 +15,11 @@ updates:
directory: "/"
schedule:
interval: daily
groups:
minor-and-patch:
update-types:
- "minor"
- "patch"
open-pull-requests-limit: 10

- package-ecosystem: "docker"
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Please note: If you wanted to work on an issue, let us know by leaving a commen

- `maintainers` label are internal tasks that will be completed by a Circuitverse core team member.
- [good first issue](https://github.com/CircuitVerse/CircuitVerse/labels/good%20first%20issue) labeled issues are meant for newer developers.
- [pending triage](https://github.com/CircuitVerse/CircuitVerse/labels/pending%20triage) labeled issues are not verified by maintainers.
- [feature](https://github.com/CircuitVerse/CircuitVerse/labels/%F0%9F%8C%9F%20feature) labeled issues are meant to propose new features.
- [bugs](https://github.com/CircuitVerse/CircuitVerse/labels/%F0%9F%90%9E%20bug) labeled issues are meant to have errors in existing code base.
- [documentation](https://github.com/CircuitVerse/CircuitVerse/labels/documentation) labeled issues are meant to have typo errors in documentation.
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem "rails_autolink"
gem "acts_as_votable", "~> 0.14.0"
gem "aws-sdk-rails"
gem "dotenv-rails", groups: %i[development test]
Expand Down
13 changes: 9 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ GEM
rails (>= 6.0)
sprockets-rails
will_paginate
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
countries (5.3.0)
unaccent (~> 0.3)
Expand Down Expand Up @@ -398,7 +398,7 @@ GEM
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest (5.21.2)
msgpack (1.6.0)
multi_xml (0.6.0)
nested_form (0.3.2)
Expand All @@ -413,7 +413,7 @@ GEM
net-protocol
newrelic_rpm (8.14.0)
nio4r (2.7.0)
nokogiri (1.16.0)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
noticed (1.6.3)
Expand Down Expand Up @@ -612,6 +612,10 @@ GEM
nested_form (~> 0.3)
rails (>= 6.0, < 8)
turbo-rails (~> 1.0)
rails_autolink (1.1.8)
actionview (> 3.1)
activesupport (> 3.1)
railties (> 3.1)
railties (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
Expand Down Expand Up @@ -728,7 +732,7 @@ GEM
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sexp_processor (4.16.0)
shoulda-matchers (5.1.0)
shoulda-matchers (6.1.0)
activesupport (>= 5.2.0)
sidekiq (7.1.4)
concurrent-ruby (< 2)
Expand Down Expand Up @@ -976,6 +980,7 @@ DEPENDENCIES
rails-erd
rails-i18n (~> 7.0.3)
rails_admin (>= 3.0.0.rc3, < 4)
rails_autolink
rbs_rails
recaptcha
redcarpet (~> 3.3, >= 3.3.4)
Expand Down
2 changes: 1 addition & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ There are several ways to run your own instance of CircuitVerse:
## Tools Setup
| Tool | Documentation Link |
| --- | --- |
| Code Auto Completion | [Click Here](https://github.com/CircuitVerse/CircuitVerse/blob/master/LSP-SETUP.MD) |
| Code Auto Completion | [Click Here](https://github.com/CircuitVerse/CircuitVerse/blob/master/LSP-SETUP.md) |
| Ruby Debugger | [Click Here](https://github.com/CircuitVerse/CircuitVerse/blob/master/DEBUGGER-SETUP.md) |

## Tests
Expand Down
Binary file added app/assets/images/empty_project/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/contribute.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
}
}

.centered-paragraph {
text-align: center;
}

//breakpoints
@media (max-width: 1199px) {
.contribute-social-card {
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ button.trumbowyg-active {
margin-bottom: 35px;
margin-top: 0;
padding: 0;
border-radius: 4px;

button {
transition: box-shadow .2s ease-in;
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
.footer-sponsor-logo-text {
margin-bottom: 0;
padding-bottom: 0;
font-size: 0.8em;
}

.footer-sponsor-logo-div{
padding-left: 12px;
padding-right: 12px;
}

.footer-sponsor-logo {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/groups.scss
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@
max-width: 90%;
}

.form-control {
border-radius: 4px;
}

.groups-background-card {
margin-top: 50px;
max-width: 80%;
Expand Down
14 changes: 7 additions & 7 deletions app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ body {
p {
overflow: hidden;
text-overflow: ellipsis;
}

&:hover .tooltiptext {
left: 50%;
opacity: 1;
transform: translateX(-50%);
visibility: visible;
z-index: 101;
&:hover .tooltiptext {
left: 50%;
opacity: 1;
transform: translateX(-50%);
visibility: visible;
z-index: 101;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
color: $navbar-dark-grey;
font-weight: 500;
transition: all .3s ease-in;
border-radius: 4px;

&:hover {
background: $primary-green;
Expand Down Expand Up @@ -155,6 +156,7 @@
min-width: 150px;
padding: 5px;
width: 100%;
border-radius: 4px;
}

.navbar-search-bar-select {
Expand All @@ -181,6 +183,7 @@
max-width: 100px;
min-width: 100px;
padding-left: 5px;
border-radius: 4px;
}

.dropdown-menu {
Expand Down
8 changes: 8 additions & 0 deletions app/assets/stylesheets/projects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
padding-top: 20px;
}

.form-control {
border-radius: 4px;
}

.projects-primary-checkpoint {
max-width: 260px;
}

.primary-checkpoint {
border-radius: 4px;
}

.projects-tag-form-group {
h6 {
display: inline-block;
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
.password-icon {
color: $secondary-green;
width: 40px;
cursor: pointer;
}

.users-password-input {
Expand Down Expand Up @@ -330,6 +331,7 @@
margin: 0;
padding: 7px 10px 7px 35px;
transition: .2s ease-in-out;
border-radius: 4px;

&:focus {
border-color: $primary-green;
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/featured_circuits_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class FeaturedCircuitsController < ApplicationController
include UsersCircuitverseHelper

before_action :authenticate_user!, except: [:index]
before_action :set_and_authorize_featured, except: [:index]

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/group_members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ def create

respond_to do |format|
format.html do
redirect_to group_path(@group),
notice: Utils.mail_notice(group_member_params[:emails], group_member_emails,
newly_added)
redirect_to group_path(@group), notice: notice
end
end
# redirect_to group_path(@group)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ProjectsController < ApplicationController
include ActionView::Helpers::SanitizeHelper
include SanitizeDescription
include UsersCircuitverseHelper

before_action :set_project, only: %i[show edit update destroy create_fork change_stars]
before_action :authenticate_user!, only: %i[edit update destroy create_fork change_stars]
Expand Down
25 changes: 14 additions & 11 deletions app/controllers/simulator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def create
@project.build_project_datum.data = sanitize_data(@project, params[:data])
@project.name = sanitize(params[:name])
@project.author = current_user

# ActiveStorage
io_image_file = parse_image_data_url(params[:image])
attach_circuit_preview(io_image_file)
# CarrierWave
image_file = return_image_file(params[:image])
@project.image_preview = image_file
attach_circuit_preview(image_file)
@project.save!
image_file.close

File.delete(image_file) if check_to_delete(params[:image])
@project.save!

# render plain: simulator_path(@project)
# render plain: user_project_url(current_user,@project)
Expand All @@ -72,17 +72,18 @@ def create
def update
@project.build_project_datum unless ProjectDatum.exists?(project_id: @project.id)
@project.project_datum.data = sanitize_data(@project, params[:data])
# ActiveStorage
@project.circuit_preview.purge if @project.circuit_preview.attached?
io_image_file = parse_image_data_url(params[:image])
attach_circuit_preview(io_image_file)
# CarrierWave
image_file = return_image_file(params[:image])
@project.image_preview = image_file
attach_circuit_preview(image_file)
image_file.close
File.delete(image_file) if check_to_delete(params[:image])
@project.name = sanitize(params[:name])
@project.save
@project.project_datum.save
image_file.close

File.delete(image_file) if check_to_delete(params[:image])

render plain: "success"
end

Expand Down Expand Up @@ -149,8 +150,10 @@ def check_view_access
end

def attach_circuit_preview(image_file)
return unless image_file

@project.circuit_preview.attach(
io: File.open(image_file),
io: image_file,
filename: "preview_#{Time.zone.now.to_f.to_s.sub('.', '')}.jpeg",
content_type: "img/jpeg"
)
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/simulator_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ def return_image_file(data_url)
image_file = File.new("tmp/preview_#{Time.zone.now.to_f.to_s.sub('.', '')}.jpeg", "wb")
image_file.write(jpeg)
end
image_file
end

def parse_image_data_url(data_url)
str = data_url[("data:image/jpeg;base64,".length)..]
if str.to_s.empty?
image_file = nil
else
jpeg = Base64.decode64(str)
image_file = StringIO.new(jpeg)
end

image_file
end
Expand Down
26 changes: 26 additions & 0 deletions app/helpers/users_circuitverse_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,30 @@ def user_profile_picture(attachment)
image_path("thumb/Default.jpg")
end
end

def project_image_preview(project, current_user)
if Flipper.enabled?(:active_storage_s3, current_user)
return_circuit_preview(project)
else
return_image_preview(project)
end
end

private

def return_circuit_preview(project)
if project.circuit_preview.attached?
project.circuit_preview
else
image_path("empty_project/default.png")
end
end

def return_image_preview(project)
if project.image_preview.present?
project.image_preview.url
else
image_path("empty_project/default.png")
end
end
end
1 change: 0 additions & 1 deletion app/javascript/src/sass/color_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ $touch-menu:#454545;
#tabsBar {
background-color: var(--bg-tabs);
border-top: 1px solid var(--br-primary);
border-bottom: 1px solid var(--br-primary);
}

#tabsBar .circuits {
Expand Down
1 change: 0 additions & 1 deletion app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Assignment < ApplicationRecord
has_noticed_notifications model_name: "NoticedNotification", dependent: :destroy

def notify_recipient
@assignment = Assignment.find(id)
group.group_members.each do |group_member|
NewAssignmentNotification.with(assignment: self).deliver_later(group_member.user)
end
Expand Down
1 change: 0 additions & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Project < ApplicationRecord
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
mount_uploader :image_preview, ImagePreviewUploader
# Mirror Uploads to ActiveStorage
has_one_attached :circuit_preview
has_one :featured_circuit
has_one :grade, dependent: :destroy
Expand Down
Loading

0 comments on commit 7ff4782

Please sign in to comment.