Skip to content

Commit

Permalink
Merge pull request #128 from publify/remove-inline-styles
Browse files Browse the repository at this point in the history
Remove inline styles assigned in ERB templates
  • Loading branch information
mvz authored Nov 12, 2023
2 parents f39643d + e5382f7 commit 63e05f4
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/optional_field_toggle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$(document).ready(function() {
$('.optional_field').hide();
$('.optional-field-toggle').on("click", function(e){
$('.optional_field').fadeToggle();
e.preventDefault();
Expand Down
9 changes: 7 additions & 2 deletions app/assets/javascripts/spinnable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Show and hide spinners on Ajax requests.
$(document).ready(function(){
$('form.spinnable').on('ajax:before', function(evt, xhr, status){ $('#spinner').show();})
$('form.spinnable').on('ajax:complete', function(evt, xhr, status){ $('#spinner').hide();})
$('#spinner').hide().removeClass("hidden");
$('form.spinnable').on('ajax:before', function(evt, xhr, status){
$('#spinner').show();
});
$('form.spinnable').on('ajax:complete', function(evt, xhr, status){
$('#spinner').hide();
});
});
2 changes: 1 addition & 1 deletion app/assets/stylesheets/administration_structure.css.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* General */

body {
padding-top: 40px;
padding-top: 60px;
}

footer {
Expand Down
22 changes: 22 additions & 0 deletions app/assets/stylesheets/publify.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,25 @@
.admin-tools-reveal:hover .admintools {
display: block;
}

.tag-sidebar-tag-cloud {
overflow: hidden;
}

.tag-sidebar-tag-67 { font-size: 0.67em; }
.tag-sidebar-tag-75 { font-size: 0.75em; }
.tag-sidebar-tag-83 { font-size: 0.83em; }
.tag-sidebar-tag-91 { font-size: 0.91em; }
.tag-sidebar-tag-100 { font-size: 1em; }
.tag-sidebar-tag-112 { font-size: 1.12em; }
.tag-sidebar-tag-125 { font-size: 1.25em; }
.tag-sidebar-tag-137 { font-size: 1.37em; }
.tag-sidebar-tag-150 { font-size: 1.50em; }
.tag-sidebar-tag-162 { font-size: 1.62em; }
.tag-sidebar-tag-175 { font-size: 1.75em; }
.tag-sidebar-tag-187 { font-size: 1.87em; }
.tag-sidebar-tag-200 { font-size: 2em; }

.hidden {
display: none;
}
28 changes: 25 additions & 3 deletions app/models/tag_sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,34 @@ def sizes
average = total.to_f / @tags.size
@sizes = tags.reduce({}) do |h, tag|
size = tag.content_counter.to_f / average
h.merge tag => size.clamp(2.0 / 3.0, 2) * 100
h.merge tag => bucket(size)
end
end

def font_multiplier
80
BUCKETS = [
67,
75,
83,
91,
100,
112,
125,
137,
150,
162,
175,
187,
200
].freeze

private

def bucket(size)
base_size = size.clamp(2.0 / 3.0, 2) * 100
BUCKETS.each do |sz|
return sz if sz >= base_size
end
BUCKETS.last
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/views/admin/articles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</p>

<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-heading clearfix">
<div class="pull-right">
<div class="form-group">
<%= select_tag('search[user_id]', options_from_collection_for_select(User.all, 'id', 'name'), prompt: t('.select_an_author'), class: 'form-control') %>
Expand All @@ -33,10 +33,9 @@
</div>
<div class="form-group">
<%= submit_tag(t('.search'), class: 'btn btn-success') %>
<span id="spinner" style="display:none;"><%= image_tag('spinner.gif') %></span>
<span id="spinner" class="hidden"><%= image_tag('spinner.gif') %></span>
</div>
</div>
<br style="clear: both">
</div>
</div>
<table class="table table-hover">
Expand Down
8 changes: 4 additions & 4 deletions app/views/articles/_comment_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_tag @article.comment_url, id: 'comment_form', remote: true do %>
<div class="comment-box">
<div id="errors" style="display: none"></div>
<div id="preview" style="display: none"></div>
<div id="errors" class="hidden"></div>
<div id="preview" class="hidden"></div>

<a name="respond"></a>
<table cellpadding="4" cellspacing="0" class="frm-tbl">
Expand All @@ -16,11 +16,11 @@
</small>
</td>
</tr>
<tr class="optional_field" style="display: none">
<tr class="optional_field">
<td><p><label for="comment_url"><%= t('.your_blog') %></label></p></td>
<td> <%= text_field 'comment', 'url' %></td>
</tr>
<tr class="optional_field" style="display: none">
<tr class="optional_field">
<td><p><label for="comment_email"><%= t('.your_email') %></label></p></td>
<td> <%= text_field 'comment', 'email' %></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/comment_failed.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var message = "<%= j render 'articles/comment_errors', comment: @comment %>";
$('#preview').hide();
$('#errors').hide().html(message).fadeIn();
$('#errors').hide().removeClass("hidden").html(message).fadeIn();
2 changes: 1 addition & 1 deletion app/views/comments/preview.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var preview = "<%= j render 'articles/comment_preview', comment: @comment %>";
$('#errors').hide();
$('#preview').hide().html(preview).fadeIn();
$('#preview').hide().removeClass("hidden").html(preview).fadeIn();
4 changes: 1 addition & 3 deletions app/views/layouts/administration.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<body>
<%= render 'admin/shared/menu' %>
<div class='container-fluid'>
<div style='margin-top:20px'>
<%= render 'shared/flash', flash: flash %>
</div>
<%= render 'shared/flash', flash: flash %>
<% if content_for?(:page_heading) %>
<div class='page-header'>
<%= yield :page_heading %>
Expand Down
1 change: 0 additions & 1 deletion app/views/search_sidebar/_content.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
<input type="submit" value="<%= t('.search') %>">
<% end %>
</div>
<br style="clear: right">
4 changes: 2 additions & 2 deletions app/views/tag_sidebar/_content.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% unless sidebar.tags.blank? %>
<h3 class="sidebar-title"><%= t('.tags') %></h3>
<div class="sidebar-body">
<p style="overflow:hidden">
<p class="tag-sidebar-tag-cloud">
<% sidebar.tags.each do |tag| %>
<span style="font-size:<%= sidebar.sizes[tag] %>%"><%= link_to tag.display_name, tag_url(tag.name) %></span>
<span class="tag-sidebar-tag-<%= sidebar.sizes[tag] %>"><%= link_to tag.display_name, tag_url(tag.name) %></span>
<% end %>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/models/tag_sidebar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
create(:article, keywords: "foo, quuz")

result = sidebar.sizes
expect(result.values.uniq).to contain_exactly (2.0 / 3.0 * 100), 200
expect(result.values.uniq).to contain_exactly 67, 200
end
end
end

0 comments on commit 63e05f4

Please sign in to comment.