Skip to content

Commit 158f8dd

Browse files
committed
Add: published_on date for projects and default sort ordering by published_on date
1 parent 1dc1854 commit 158f8dd

14 files changed

Lines changed: 96 additions & 15 deletions

File tree

app/controllers/admin/projects_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def set_technologies
9595
def project_params
9696
params.require(:project).permit(
9797
:collage, :collage_cache, :project_id, :screenshot_id, :row_position, :shortlink, :title, :description,
98-
:row_tech_position, :project_technology_id, :keywords, :content, :livelink, :publish,
98+
:row_tech_position, :project_technology_id, :keywords, :content, :livelink, :publish, :published_on,
9999
technology_ids: [],
100100
technologies_attributes: %i[id title technology_group_id],
101101
screenshots_attributes: %i[id file file_cache project_id position _destroy]

app/controllers/home_controller.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ def index
1010
end
1111

1212
def portfolio
13-
@projects = Project.published.rank(:position).includes(:translations, :screenshots,
14-
{ technologies_projects: :technology },
15-
{ technologies: :translations },
16-
:technologies).page(params[:page]).per(10)
13+
@projects = Project.published
14+
.includes(:translations, :screenshots,
15+
{ technologies_projects: :technology },
16+
{ technologies: :translations },
17+
:technologies)
18+
.order(Arel.sql('COALESCE(projects.published_on, projects.created_at) DESC'))
19+
.page(params[:page]).per(10)
1720
end
1821

1922
def team

app/views/admin/projects/_form.html.slim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
= f.input :title, label: t('activerecord.project.title'), label_html: { class: 'label' }
55
= f.input :content, label: t('activerecord.project.content'), label_html: { class: 'label' }, as: :ckeditor, input_html: { ckeditor: { toolbar: 'mini' } }
66
p= f.input :livelink, as: :url, label: t('activerecord.project.livelink'), label_html: { class: 'label' }, placeholder: 'https://webgate.pro'
7+
= f.input :published_on, as: :string, label: t('activerecord.project.published_on'), label_html: { class: 'label' }, input_html: { type: 'date' }
78
.label= t(:publish)
89
- @project.collage.to_s.empty? ? disabled = true : disabled = false
910
= f.input :publish, label: t('activerecord.project.publish'), disabled: disabled

app/views/home/portfolio.html.slim

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@
1616
= link_to project.title, project.livelink, class: 'work_link', target: '_blank', rel: 'nofollow'
1717
- full_html = HtmlTranslationNormalizer.call(project.content.to_s)
1818
- full_id = "project_full_#{project.id}"
19-
p.project-content-tooltip data-full-id="##{full_id}"
20-
= truncate_plain_text(full_html, length: 270)
21-
.project_full_content id=full_id
22-
= full_html.html_safe
19+
- plain_full = ActionView::Base.full_sanitizer.sanitize(full_html.to_s)
20+
- plain_full = CGI.unescapeHTML(plain_full.to_s).tr("\u00A0", ' ').gsub(' ', ' ').gsub(/\s+/, ' ').strip
21+
- show_full_tooltip = plain_full.length > 270
22+
- truncated_plain = truncate(plain_full, length: 270, omission: '...')
23+
- if show_full_tooltip
24+
p.project-content-tooltip data-full-id="##{full_id}"
25+
= truncated_plain
26+
.project_full_content id=full_id
27+
= full_html.html_safe
28+
- else
29+
p = truncated_plain
2330
.work_info
2431
p
2532
em = t(:used_technologies)
@@ -31,6 +38,9 @@
3138
= link_to tech.title, tech_link(tech), data: { title: tech.title, desc: tech.description }, class: 'tooltipstered', rel: 'nofollow', target: '_blank'
3239
- unless tech == project.technologies.last
3340
|, 
41+
- if project.published_on
42+
p
43+
= "#{t(:year)} #{project.published_on.strftime('%Y')}"
3444
= paginate @projects
3545

3646
javascript:

config/locales/carriervawe.en.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ en:
1010
mime_types_processing_error: "Failed to process file with MIME::Types, maybe not valid content-type? Original Error: %{e}"
1111
mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}"
1212
min_size_error: "File size should be greater than %{min_size}"
13-
max_size_error: "File size should be less than %{max_size}"
13+
max_size_error: "File size should be less than %{max_size}"
14+
year: ""

config/locales/de.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ de:
4242
content: Inhalt
4343
livelink: Live-Link
4444
publish: Veröffentlichen
45+
published_on: Veröffentlichungsdatum
4546
title: Titel
4647
subcategory:
4748
altlink: Alternativlink
@@ -192,7 +193,7 @@ de:
192193
to_top: Nach oben
193194
use_our_form_or_call: per E-Mail, über das Kontaktformular auf der Website oder
194195
rufen Sie einfach an.
195-
used_technologies: 'Verwendete Technologien:'
196+
used_technologies: 'Technologien:'
196197
user: Benutzer
197198
users: Benutzer
198199
views:
@@ -234,3 +235,4 @@ de:
234235
technology_group: Technologiegruppe
235236
user: Benutzer
236237
users: Benutzer
238+
year: "Jahr:"

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ en:
4343
content: Content
4444
livelink: Live link
4545
publish: Publish
46+
published_on: Publication date
4647
title: Title
4748
subcategory:
4849
altlink: Altlink
@@ -229,3 +230,4 @@ en:
229230
technology_group: technology group
230231
user: user
231232
users: Users
233+
year: "Year:"

config/locales/fr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fr:
4343
content: Contenu
4444
livelink: Lien en direct
4545
publish: Publier
46+
published_on: Date de publication
4647
title: Titre
4748
subcategory:
4849
altlink: Lien alternatif
@@ -165,7 +166,7 @@ fr:
165166
three_chars_minimum: Minimum 3 caractères
166167
to_top: en haut
167168
use_our_form_or_call: Vous pouvez utiliser l'email, notre formulaire de contact ou simplement appeler.
168-
used_technologies: 'Technologies utilisées:'
169+
used_technologies: 'Technologies:'
169170
user: Utilisateur
170171
users: Utilisateurs
171172
views:
@@ -208,3 +209,4 @@ fr:
208209
technology_group: groupe technologique
209210
user: utilisateur
210211
users: Utilisateurs
212+
year: "Année:"

config/locales/pl.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pl:
4242
content: Treść
4343
livelink: Link na żywo
4444
publish: Publikować
45+
published_on: Data publikacji
4546
title: Tytuł
4647
subcategory:
4748
altlink: Alternatywny link
@@ -231,3 +232,4 @@ pl:
231232
technology_group: grupa technologii
232233
user: użytkownik
233234
users: Użytkownicy
235+
year: "Rok:"

config/locales/ru.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ru:
4242
content: Содержимое
4343
livelink: Ссылка на проект
4444
publish: Опубликован
45+
published_on: Дата публикации
4546
title: Название
4647
subcategory:
4748
altlink: Альтернативный линк
@@ -185,7 +186,7 @@ ru:
185186
three_chars_minimum: Минимум 3 символа
186187
to_top: наверх
187188
use_our_form_or_call: с помощью электронной почты, контактной формы или просто позвоните.
188-
used_technologies: 'Используемые технологии:'
189+
used_technologies: 'Технологии:'
189190
user: Пользователь
190191
users: Пользователи
191192
views:
@@ -227,3 +228,4 @@ ru:
227228
technology_group: группа(у) технологий
228229
user: пользователь
229230
users: Пользователи
231+
year: "Год:"

0 commit comments

Comments
 (0)