Commit graph

2887 commits

Author SHA1 Message Date
Arit Amana
4f1bdcda22
[Small Wins] Show character limits for profile inputs (#15255)
* Start implementation

* Extend raw implementation; will refactor later

* still building

* basic implementation

* create JS pack

* Rename JS pack; use existing CSS property

* complete implementation for profile fields

* Add guard againt irrelevant profile fields

* extract view logic to helper and add specs
2021-11-05 09:11:42 -04:00
Akash Srivastava
4cb48768f9
Added collapsed hidden comments to author's article/podcast episode view (#14018)
* Handling hiding/collapsing hidden comments client side

* Updated comment quality text

* Added placeholder for comments against podcast episodes

* Added logic for encompassing co-author-ids in articles

* Removed rspecs validating non-presence of hidden comments in dom

* Fixed hiding flow on comments page for a commentable

* Fixed e2e specs

* Addressed feedback on e2e tests
2021-11-03 11:08:04 +07:00
Lewis Sparlin
71e90a41f5
Disable all providers when providers_to_enable param is blank (#15260)
* Disable all providers when providers_to_enable param is blank

* Remove guard, a couple more spec examples

* Update app/services/settings/authentication/upsert.rb

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2021-11-02 21:20:26 -04:00
Kushal Niroula
87244c345c
Fix: cannot unpin articles using checkbox (#15090)
Co-authored-by: rhymes <github@rhymes.dev>
Co-authored-by: Arit Amana <msarit@gmail.com>
2021-11-02 13:50:56 -04:00
Daniel Uber
e3ebc623da
Compare the utc offset from the timestamp, not now (#15256)
Time Zones are political things, and move. The timezone database knows
this, and correctly interprets times as they would have been at the
time.

For example, when the Time zone is Africa/Monrovia, the offset now is
0, but the offset in 1970 was -44.5 minutes, so Time.zone.at(0) is Dec
31st, 1969, 23:15:30 and not Jan 1st, 1970 00:00:00.

Prevent this spec from randomly failing based on Zonebie's selected
timezone by comparing the offset _then_ against UTC, and predicting
whether the 60's have ended yet.
2021-11-01 15:49:35 -05:00
Julianna Tetreault
4a9f442354
Creator Onboarding: Creator Setup View (#14728)
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Yhëhtozr <conlang2012@outlook.com>
Co-authored-by: yheuhtozr <84892012+yheuhtozr@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2021-11-01 15:50:08 -04:00
Daniel Uber
43adc9f1fb
cross posted articles showing <time> tag (#15224)
* Maybe this is what we need to do?

* Undo change to keyword

Use the on_html translation in the view, but pass 'on' as a keyword to
the template.

* remove unused translation

Since we only want to use views.articles.crossposted.on.html (and this is only used in the
article show template) - remove the unused 'on' key from the
translations file.

* Add a spec

Tested that this fails in main and passes on the branch

* Check that the original publication date is shown in the users local

And that it's not a <time> tag presented as text

* Correct local date selection error

If time zone was UTC (i.e. offset from utc was 0) the check for
positive? was false, I meant "non-negative" (positive or zero). Invert
the test.
2021-10-29 12:10:53 -05:00
Ridhwana
aa6d80bc5d
Only enable user invitations page when SMTP is enabled (#15219)
* first pass of styling of the page

* feat: scroll to the position in the config controller in stimulus

* feat: add the tooltip and a cursor thats not allowed

* feat: add a disabled property for all that needs smtp to be enabled

* feat: update the form styling

* feat: update the form

* specs: update the label name

* fix: syntax error

* chore: update the newline

* spec: test the invitation flow

* fix test

* feat: update the form as per suggestions

* spec: update the tests to match the new workflow

* oops committed debugging code

* chore: add a before to set the smtp_enabled method

* feat: update the boldness and fontsize of the link

* feat: remove size
2021-10-29 17:41:30 +02:00
Arit Amana
20c164ce40
[Small Win] Assign 'trusted' role when user updated to Admin or SuperAdmin (#15215)
* Bada bing, bada boom! 💥

* Give default admin user "trusted" role

* fix failing spec
2021-10-28 15:28:25 -04:00
Michael Kohl
0fab8d6634
Theming changes part 1: Rename default and night_theme (#15176) 2021-10-28 07:55:46 -04:00
ludwiczakpawel
ca108aa9c8
Videos UI update (#15177)
* videos ui updates

* move cheese around

* .

* .

* thumbnail yolo

* thumbnail yolo

* object fit

* aspect ratio yolo

* .

* loading videos

* Make Travis and asset pipeline happy with .mp4 extension

* Use Cloudinary video url, testing for Travis

* Try weird things

* Try a real image url

* Use a real image instead of 'video' string

* Update views.scss

Co-authored-by: Andy Z <17884966+Zhao-Andy@users.noreply.github.com>
2021-10-28 09:34:44 +02:00
Mac Siri
3c204c236d
Update TagsController#index query (#15202)
* Update TagsController#index query

to include empty string

* Update spec
2021-10-27 08:17:53 -04:00
Jeremy Friesen
ed78f8f479
Extracting a common calculator for feed weights (#15199)
Prior to this commit, there existed duplicate logic between two of the
primary user feeds.  This refactor introduces a new object which is
solely concerned with calculating scores to add to an article base score.

With this commit, we can introduce A/B testing by changing passing
different config values to `ArticleScoreCalculatorForUser.new`.

My suspicion is that for some of this, we might be able to better
leverage the database via select statements and SQL sums.  However, that
is presently outside of what I'm prepared to tackle.
2021-10-27 04:45:53 -04:00
Ben Halpern
2395693809
Asynchronously detect image aspect ratios and apply proper attributes (#15170)
* Initial work to expand detection functionality

* Finish up functionality and tests

* Fix class name

* Fix tests

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-26 13:39:25 -07:00
Jeremy Friesen
fbce226c08
Low Stakes Refactor of Feed class (#15180)
* Removing state change and unused method

Prior to this commit, the `@comment_weight` value would change.  This is
not ideal as depending on the call sequence, can notably change the
output.  I suspect this state change occurred so as to not alter an
underlying spec.

What this change does is remove the state change, removes a dead method,
renames a method (to the dead method name), and leverages
parameterization to better test a spec that was brittle based on
possible state changes.

I believe, from a logical stand point, that this change does not impact
the functionality nor the actual logic that is part of the production
call path.

* Marking methods as @api private

The goal is to highlight that we really shouldn't be calling these
outside of their contained class.  Ideally, I'd love to make them
private methods, but there are specs and would prefer to not use
`__send__` to change those specs.

This is a noop change.

* Renaming method to refelct returned param order

Prior to this commit the "default_home_feed_and_featured_story" returned
an array of `[featured_story, default_home_feed]`.  The method name and
the order of the returned values were misaligned.  This change helps
align the method name and the order of those returned values.

Note, methods such as `each_with_index` have an `element, index`
parameter order.
2021-10-26 09:57:33 -04:00
ludwiczakpawel
88a3b573ea
Page headers unified (#15158)
* fix; remove the bottom 100%

* dashboard

* fixes + magic border-radius

* everything

* fix

* fix

* spec

* split PRs

* Update app/assets/stylesheets/views/listings.scss

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2021-10-25 21:41:29 +02:00
yheuhtozr
6a3a91d9b7
views/podcasts, views/podcast_episodes i18n (#15020)
* views/podcasts, views/podcast_episodes i18n

* reformat for PR

* helper labels

* PR sync with main

* remove ja.yml

* Update en.yml

* Update fr.yml

* Update _meta.html.erb

* Update podcast_episodes_index_spec.rb

* Update podcast_create_spec.rb

* Update user_visits_podcast_episode_spec.rb

* Update en.yml

* Update feed.rb

* Update index.html.erb
2021-10-25 14:32:51 +01:00
ludwiczakpawel
719b87e2ae
Auto border-radius (#15165) 2021-10-25 14:41:13 +02:00
ludwiczakpawel
656cfcd655
Tag edit (#15173)
* tag edit

* more

* chop chop

* spec

* Apply suggestions from code review

Co-authored-by: Michael Kohl <me@citizen428.net>

* french translation

* Fix I18n usage

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* lang

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Michael Kohl <citizen428@forem.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-10-25 12:50:00 +02:00
Lewis Sparlin
e621659279
Add Article post_commit when user_id changes with specs (#15132)
* Add Article post_commit when user_id changes with specs

* Add example in requests/admin/articles_spec for updating user
2021-10-25 10:53:21 +07:00
ludwiczakpawel
d1aac57053
Podcasts fixes (#15130) 2021-10-22 11:06:11 +02:00
Nick Taylor
bf2d673492
Created the Forem creator confirmation email template (#14659)
Co-authored-by: Michael Kohl <citizen428@forem.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2021-10-21 14:56:09 -04:00
Arit Amana
55a6bc3644
Allow users to choose their default Home and Tags-View Feed (Part 1) (#15128)
* add new column & define enums

* add new column & define enums

* add tests; improve enum naming

* complete specs update 😅

* discard changes to schema.rb

* rename column name more appropriately

* update specs

* update specs properly 🤦🏾‍♀️

* Please Travis do the thing

* Add DB schema diff

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2021-10-20 18:02:59 -04:00
Julianna Tetreault
22d1e6dd83
Adds a Creator user to the users.rb for testing purposes (#15138) 2021-10-20 07:15:41 -06:00
Michael Kohl
26aef9da93
Don't notify authors about own org posts (#15113) 2021-10-19 21:32:44 +07:00
Suzanne Aitchison
5069cd681a
Markdown editor toolbar (#14876)
* rough starting point, roving tabindex in toolbar, bold and italic buttons

* refactor, add link

* add ul

* add ordered list

* core formatters in place, wip

* overflow options

* add keyboard shortcuts

* tidy up some dodgy classes

* add mocks for runtime in test and storybook, use correct modifier key for tooltip

* style tweaks

* refactor tooltips

* add markdown formatters tests

* add tests for toolbar component, fix mistake in overflow menu tooltips

* undo change no longer needed to button

* fix issue accessing runtime in formatters file

* only show darkened buttons and tooltips when focus-visible is true

* mobile view

* fix for responsive buttons & roving tabindex

* tweaks from PR review

* update cursor position on link insertion

* add a new line after block selection formatting

* align icons in center

* tidy up overflow menu listeners

* small refactors

* test for new text area util

* tidy up new lines after syntaxes

* fix logic in cursor offsets for links

* prevent scroll jumps after inserting syntax

* some style tweaks

* insert level 2 heading with new lines above and below

* update icons

* use margin instead of gap
2021-10-19 09:22:54 +01:00
Ben Halpern
09fa66a03f
Fix and clean up podcast pages (#15004)
* Fix and clean up podcast pages

* Adjust tests

* Fix a test

* Fix missing i18n

* Fix tests

* Fix tests

* Fiddle with test

* Sure up css and tests

* Add featured as allowed param

* Fix a couple tests

* xit out test

* Update app/views/podcast_episodes/index.html.erb

* Update app/views/podcast_episodes/index.html.erb

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>
2021-10-15 17:38:57 -04:00
Jamie Gaskins
820dd9b5a6
Allow Emails::RemoveOldEmailsWorker to run longer (#15085)
* Allow Emails::RemoveOldEmailsWorker to run longer

We set the SQL statement timeout based on the STATEMENT_TIMEOUT
environment variable (defaulting to 2.5 seconds in production), but not
all SQL queries are created equal. Since some may take longer out of
necessity, this PR introduces a `Model.with_statement_timeout` method
that allows you to change the SQL statement timeout only for a given
block.

* EmailMessage doesn't inherit ApplicationRecord

It inherits from `Ahoy::Message`, which inherits directly from
`ActiveRecord::Base`.

[3] pry(main)> EmailMessage.ancestors
=> [EmailMessage(id: integer, clicked_at: datetime, content: text, feedback_message_id: integer, mailer: string, sent_at: datetime, subject: text, to: text, token: string, user_id: integer, user_type: string, utm_campaign: string, utm_content: string, utm_medium: string, utm_source: string, utm_term: string),
 EmailMessage::GeneratedAssociationMethods,
 EmailMessage::GeneratedAttributeMethods,
 Ahoy::Message(id: integer, clicked_at: datetime, content: text, feedback_message_id: integer, mailer: string, sent_at: datetime, subject: text, to: text, token: string, user_id: integer, user_type: string, utm_campaign: string, utm_content: string, utm_medium: string, utm_source: string, utm_term: string),
 Kaminari::ConfigurationMethods,
 Kaminari::ActiveRecordModelExtension,
 Ahoy::Message::GeneratedAssociationMethods,
 Ahoy::Message::GeneratedAttributeMethods,
 Bullet::SaveWithBulletSupport,
 ActiveRecord::Base,
 ...

* Use milliseconds to match STATEMENT_TIMEOUT units
2021-10-15 11:53:55 -04:00
Michael Kohl
a1f512e49e
✂✂✂ Remove events (#15062)
* Remove events

* Fix schema

* Fix specs

* More removal
2021-10-15 09:31:08 -04:00
Ben Halpern
333775b831
Admin productivity: Allow admins to unpublish all posts from a user (#15054)
* Allow admins to unpublish all posts from a user

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Unset `published` irrespective of front matter

* Change to worker and make other adjustments

* Fix controller test

* Fix object name

* Update app/views/admin/users/edit.html.erb

Co-authored-by: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com>

* Update spec/requests/admin/users_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

Co-authored-by: Jamie Gaskins <jamie@forem.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com>
2021-10-15 08:56:59 +02:00
Lewis Sparlin
ff5a94dbf3
Fix notifications not deleting because mentions already destroyed (#14987)
* Fix notifications not deleting because mentions already destroyed

* Fix spelling in spec

* Use rspec expect/to assertions for delete notification spec clarity

* resolve failing spec, and remove need for environment check 🎉
2021-10-14 09:41:10 -06:00
VISHAL DEEPAK
3964bd7983
When a user is blocked from commenting on an article, show correct error message (#15009)
* When a user is blocked from commenting on an article, show correct error message

* Created new error type ModerationUnauthorizedError and changed error text for it
2021-10-14 07:42:08 -06:00
Daniel Uber
3167ff44d7
Change fixed organization id to fixed organization slug (#15067)
* Remove hard coded organization id from seed

Since we create (hopefully) an organization with a known slug, use
find_by here to set the organization_id on the seeded DisplayAd.

* Since the DisplayAd looks by slug, create org if slug not found

Change the seed guard to ensure an organization with slug "bachmanity"
is present - we'll find by slug in DisplayAd (rather than assuming
this is id 1).
2021-10-13 11:18:54 -05:00
Ben Halpern
b900c8de92
Remove legacy "deleted commentable" view (#15052)
* Remove unneeded extra page

* Update app/views/comments/index.html.erb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update app/views/comments/index.html.erb

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-13 10:23:25 -04:00
Ben Halpern
549336b0a2
Delete old retained emails after certain period (#14949)
* Delete old retained emails after certain period

* Update app/models/email_message.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update spec/workers/emails/remove_old_emails_worker_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/models/email_message.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

Co-authored-by: Jamie Gaskins <jamie@forem.com>
2021-10-12 16:27:13 -04:00
Jamie Gaskins
29fb20cd83
Transliterate article titles to slugs (#15051) 2021-10-12 12:35:32 -04:00
Daniel Uber
5c69cf5880
Make e2e seed safe to run twice (#15049)
* Make e2e seed safe to run twice

We have a number of checks in the seed file that prevent creating
objects if they're found in the database, but nothing is guarding
against this breaking.

Change a few create! to create_with().find_or_create_by() and update
guard clauses where we create if doesn't exist to match the objects
created. These had drifted, preventing subsequent runs of the seed in
a "dirty" database. In CI we're typically creating a new database,
loading schema, and only running this once, so the guards are never
checked and the objects are always created, but locally that might not
always be the case.

* Update multiple guards

We're creating test users against @forem.local domain, let's check
that there's not already a forem.local user with the same email
account.

Additionally, something was causing the "find article by title" to
miss identifying the commented article, but it was not create()'d due
to a slug collision, and the comment could not be created. Update the
call to use `create!` instead (since we rely on it existing in the
comment create) and guard against the slug instead of the title.
2021-10-12 10:43:08 -05:00
Ben Halpern
ebc2961920
Translate pinned (#15008)
* Translate pinned

* Add pinned
2021-10-12 08:24:29 -04:00
Jamie Gaskins
70cf28ca7b
Fix rotation of images uploaded from iPhones (#15010)
* Fix rotation of images uploaded from iPhones

iPhones[1] take pictures in portrait mode with the orientation set to
90ºCCW. We noticed that uploading one of these images to a Forem
instance caused the image to be rotated when rendered. The current
theory is that Imgproxy is not maintaining the orientation value when
processing, which is solved by setting `auto_rotate: true` (serialized
into the Imgproxy URL as `ar:1`), according to the documentation.

See: 8e6585e28d/docs/generating_the_url_advanced.md (auto-rotate)

[1] This probably happens with other phones, but we discovered the issue
using an iPhone.

* Fix Imgproxy URL expectation for auto_rotate
2021-10-11 15:17:14 -04:00
Ben Halpern
3f921ec9c6
Fix profile image bug on email registration (#14991) 2021-10-08 14:30:57 -04:00
Lewis Sparlin
30b36ab014
I18n copy on Tags index page (#14891)
* Move hard-coded Tags index copy to [en,fr] locale files

* Use tags.pluralize for a better page title implementation

* Add better french translations

* Once more fr translation fix

* Remove .pluralize from title i18n
2021-10-08 10:21:06 +07:00
Ben Halpern
b0a79da072
✂️✂️✂️ Remove boosted states from articles (legacy/dead code) (#14977)
* Remove boosted states from articles (legacy/dead code)

* Fix indentation
2021-10-07 14:39:34 -04:00
Ben Halpern
1d62d30853
Consolidate and internationalize various 'contact us' prompts (#14951)
* Consolidate and internationalize various 'contact us' prompts

* Update spec/requests/user/user_settings_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-07 12:05:21 -04:00
Andy Zhao
f5d0c3be31
Fix small bugs related to identities when merging a user (#14885)
* Only prevent merge user if 2+ more identities, not 1+ more

* Refactor error messages into constants

* Skip only if no identities on deleted user

* Raise standard error instead of a string

* Add test to confirm correct identity was merged
2021-10-07 10:08:02 -04:00
Ben Halpern
d85f07c00d
Fix legacy sitemap logic (#14926)
* Fix legacy sitemap logic

* Add aggregate failures

* Fix formatting

* Adjust robots.txt spec

* Fix index minimum to >=
2021-10-07 08:59:16 -04:00
Andy Zhao
0c28781c47
Remove tag categories from admin UI and remove aliased tags from /tags page (#14966)
* Don't show aliased tags in top 100 tags page

* Remove tag category from admin UI and controller params

* Fix styling of checkbox
2021-10-06 14:45:51 -04:00
Monica Mateiu
bd0b4f1117
Tokenize settings menu and add French translations (#14905)
* tokenize settings menu and add French translations

* add quotes around tokens

* add tokens in alphabetical order

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2021-10-06 17:53:58 +02:00
Mohamed Asan N
cceb175d5d
Use section instead of header in dashboard pages (#14873)
* Use section instead of header

* Trigger Build

* Move section inside main

* Fix test case

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2021-10-06 17:12:43 +02:00
Alex
eed3c12f4d
Auto register Forems on Discover (#14962) 2021-10-06 10:51:15 -04:00
Takuma
baab2c0930
Subscribe the newsletter if email_newsletter is changed (#14226)
* Check if email_newsletter is changed

* Check if Settings::General.mailchimp_api_key is defined

* Add spec for Users::NotificationSetting

* Remove spec for boolean column

http://www.chrisrolle.com/en/blog/boolean-attribute-validation

* Check if email is set when changing newsletter subscription setting

* Make it easy to read

* Remove specs for a case never happening
2021-10-06 12:30:22 +07:00