Commit graph

32 commits

Author SHA1 Message Date
Jeremy Friesen
0c6b6b9e62
Ensuring that embed fallback renders URL (#17680)
Prior to this commit, our fallback HREF was using only the URL's
domain (e.g. `guides.rubyonrails.org/routing.html`) instead of the
provided URL (e.g. `https://guides.rubyonrails.org/routing.html`).  This
resulted in the link resolving to
`<url-of-article>/guides.rubyonrails.org/routing.html`)

With this commit, we're using the given URL for the HREF.

An interesting side note, the Ruby on Rails guides includes an
`og:title` but not an `og:url` so we hit the fallback condition.  Could
we use the given URL if `og:url` does not exist?

Fixes forem/forem#17679
2022-05-17 07:43:17 -04:00
Jeremy Friesen
0d0464be2f
Allowing VariantQuery for Feed Generation (#17382)
* Allowing VariantQuery for Feed Generation

Apologies for the breadth of this pull request, I had considered many
small commits, but felt that would've been more effort for the value
provided.

This commit includes the following:

- Documentation updates to the feed variant (though not the final pass)
- Renaming and adding RelevancyLevers that help differentiate
- Adding RelevancyLever#range to provide documentation
- Reducing redundent controller logic by making a
  `Articles::Feeds.feed_for` method.
- Adding some configuration validation for RelevancyLevers
- Adding constants for better clarification
- Testing unhappy paths for feed configuration
- Adjusting the module namespace of some objects
- Exposing top-level configurations for variants (along with their
  defaults)
- Creating the VariantyQuery that at present inherits from the
  `Articles::Feeds::WeightedQueryStrategy`

As implemented, we can deploy this code to production without using the
new VariantQuery.  Once we toggle on the
`:feed_uses_variant_query_feature` FeatureFlag, it will switch to using
the VariantQuery.  The VariantQuery's two variants and the
internal configuration of `Articles::Feeds::WeightedQueryStrategy`
produce the same query.

The goal of this factor is to allow for a quick on and off toggle of the
feed query; to ensure that what we introduce remains performant.

- Closes forem/forem#17272
- Closes forem/forem#17276
- Closes forem/forem#17216

In addition, I will be recording a code-walkthrough and linking that
recording to the pull request.

* Apply suggestions from code review

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-04-21 11:07:09 -04:00
Michael Kohl
43ccdb31f1
Remove duplicated work display from header / profile work (#14210)
* Remove duplicated work display from header

* Update work profile field handling

* Update DUS + spec

* Delegate more carefully

* Update delegation guard

* Adapt for removed delegation

* Undo accidental schema changes

* Fix seeds

* Remove accidentaly change

* Fix User#processed_website_url

* Update guard clause

* Update profile card content

* Add Organization#profile

* Be more conservative with profile fields

* Spec fixes round 1

* Fix typo

* Update spec

* Limit number of header fields and update card content

* Decorate correct model

* Update factory

* Update schema.rb

* Fix validation

* How bad could this possibly be?

* Pretty bad, nevermind

* Remove obsolete code

* Reset profile fields during test runs

* Move profile fields back to before(:suite)

* Spec fixes

* Remove accidentally re-added files

* More spec fixes

* Specs

* Change User#tag_keywords_for_search

* More spec fixes

* Add comment

* Undo accidental schema changes

* Attempt spec fix

* Remove fix attempt

* Fix e2e test

* Update spec

* Remove guard clause

* Remove outdated guard clause

* Re-add validation

* Update header field validation

* Fix auto-complete fail
2021-07-30 12:28:40 +02:00
Michael Kohl
84a85fe1a4
Remove color_field input type from profiles (#14239)
* Move brand color validation to Users::Setting

* Fix specs

* Remove color_field as ProfileField input type
2021-07-19 18:42:36 +07:00
Vaidehi Joshi
3f6600541e
✂️ Remove the approvals gem ✂️ (#12978)
* Remove approvals fixtures

* Remove approvals initializer

* Remove approvals gem

* Remove approvals step from travis.yml

* Remove approvals from dockerignore and gitignore

* Remove references to approvals gem in docs

* Un-approvals spec/liquid_tags/codepen_tag_spec.rb

* Un-approvals spec/liquid_tags/dotnet_fiddle_tag_spec.rb

* Temporarily skip other approvals tests

We will still need to delete files in /spec/fixtures/approvals after this.

* Revert changes to dotnet_fiddle_tag_spec and codepen_tag_spec, skip those tests instead

* Temporarily skip more approvals based tests

* Attempt at moving html doc inline

* Comment out one more approvals spec

* Update dotnet fiddle and codepen liquid tag specs to not use Approvals

* Update liquid tag specs + system specs to not use Approvals

* Un-approval feed import, github issue, and tweet tag specs

* Re-add .approvals to gitignore and dockerignore

* Use Rspec compound expectations
2021-03-19 13:28:06 -07:00
Ridhwana
19a048ecec
Deployment Task: Update onboarding fields prior to #11629 (#11704) 2020-12-07 14:57:18 -05:00
Michael Kohl
8f5cfa2c0f
Drop profile columns from user (#10707)
* Prepare to drop profile columns from user

* Update code and factory

* Also remove unused constant

* Move validation from user to profile

* Remove Profiles::ExtractData service object

* Add more comments

* Simplify sameAs attribute generation

* Obey me machine, I am your master

* Fix condition order in guard clause

* Temporarily disable callback

* Fix specs

* Reduce usage of Profile#refresh_attributes!

* Remove leftover comment

* Handle social media links differently

* More spec fixes

* Fix specs for admin profile fields controller

* Fix specs after merge

* Fix remaining specs

* Update user show request spec

* Add comment for follow_hiring_tag

* Only save profile when user is valid

* Fix seeds.rb for profile fields

* Switch from before_save to after_save

* Undo unrelated formattin change

* Update spec/fixtures/files/profile_fields.csv

Co-authored-by: Molly Struve <mollylbs@gmail.com>

* Remove data update script and spec

* Fix spec

* Fix typo in comment

* Fix typo in comment

* Move article resave logic to service object

* Move profile field creation to before(:suite)

* Refactor error handling in Profiles::Update

* Fix Profiles::Update specs and refactor

* Temporarily disable spec

* Add ProfileValidator

* Clean up

* Move DB ready check into app/lib

* Refresh attributes after importing from CSV

* Fix specs

* Remove unused file

* A girl has no name. A profile neither.

* Fix specs

* Add responds_to? check

* Spec fix

* Add name to user fields in profile settings page

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-12-03 08:14:38 +07:00
Akash Srivastava
ebd7712829
fix: Parsing of preamble with escaped content in runkit tags (#11466) 2020-11-27 16:56:52 -05:00
Michael Kohl
d64943958d
Prepare for profile column drop (#11246)
* Add new display area for settings only fields

* Update CSV importer

* Prepare for dropping profile columns from user

* Update spec

* Don't migrate nil values

* Update spec

* Update forem:setup task
2020-11-09 10:17:39 +07:00
rhymes
47624ddfcd
Add users param to Feeds::Import (#11234)
* Add users param to Feeds::Import

* Fix init and specs

* Replace explicit nil check

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

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-11-03 07:02:17 -06:00
rhymes
51a4a35448
Add Feeds::Import service class (#10998)
* Add the parallel gem

* Add prototype version of Feeds::Import with parallel URL fetching and parsing

* Tune Feeds::Import and add rake task for local tests

* Add rough measurer tool

* Add specs

* Apply suggestions by @citizen428

* Replace silence with silent

* No need for eager loading

* Add temporary Articles::DevFeedsImportWorker

* Remove temporary rake task

* Add basic error handling, copied from RssReader

* Fix error handling

* Remove temporary measuring rake task

* Remove logging added for development purposes

* Add info and error logging on error level
2020-10-30 15:01:44 +01:00
Lisa Sy
3377b5b69e
Update [authentication] in /admin/config (#10748)
* Write up new accordion view in markup

* Add inline SVG and edit padding of form

* Fix padding

* Remove extraneous buttons for current draft
2020-10-13 16:43:29 -04:00
Arit Amana
f4bd1df21c
[Email/Password Authentication] Allow Admins to enable email/password login (#10745)
* Implement Admins ability to allow email login

* Write specs for admin allow email login

* Fix specs causing builds to fail

* Fix spec causing builds to fail

* Use dummyimage.com for spec images

Co-authored-by: Josh Puetz <joshpuetz@gmail.com>

* Use dummyimage.com

* refactor setting of SiteConfig attributes

* Address PR review comments

* fix indentation

* Use "allow to receive and return" approach for other specs

Co-authored-by: Josh Puetz <joshpuetz@gmail.com>
2020-10-12 12:54:35 -04:00
Nick Taylor
6f86573dbf
Removed the autoprefixer-rails deprecated gem (#10017)
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2020-08-26 17:38:24 -04:00
Michael Kohl
c2d23cfc4d
[deploy] Seed profile fields (#9605)
* Fix schema.rb

* Add service objects for base and link fields

* Add link fields to seeds

* Make placeholder a keyword argument

* Add work fields

* Add explanation column to profile fields

* Add coding fields

* Switch from inheritance to mixin

* Add email checkbox to base fields

* Add branding fields

* Add spec for ProfileFields::FieldDefinition

* Move migration back into correct location

* Rename column from explanation to description

* Rename attribute in mixin

* chore: rename from explanation to description

* Add ProfileFields::ImportFromCsv

* Simplify ProfileFields::ImportFromCsv

* Add comment about disabled cop to spec

* Add TODO comment to Rake task

* Document mixin

* Add groups to profile fields

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2020-08-05 10:11:30 -04:00
Molly Struve
66c70d38e8
[deploy] Bug Fix: Validate GIFs Frames and Add MiniMagick Timeout (#9319) 2020-07-15 09:49:24 -05:00
Mac Siri
559fc5b446
Remove inline style from KatexTag template (#8833) 2020-06-23 08:56:01 +02:00
Michael Kohl
019ce5e0d8
Add overflow-x to KaTeX liquid tag (#8818)
* Add overflow-x to KaTeX liquid tag

* Update approval snapshot

* Update approved file

Co-authored-by: rhymes <rhymesete@gmail.com>
2020-06-22 13:24:53 -04:00
dependabot-preview[bot]
9cadeaaac3
Bump sprockets from 4.0.0 to 4.0.2 (#8327)
* Bump sprockets from 4.0.0 to 4.0.2

Bumps [sprockets](https://github.com/rails/sprockets) from 4.0.0 to 4.0.2.
- [Release notes](https://github.com/rails/sprockets/releases)
- [Changelog](https://github.com/rails/sprockets/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/sprockets/compare/v4.0.0...v4.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Fix spec

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: rhymes <rhymesete@gmail.com>
2020-06-08 10:50:36 -04:00
rhymes
300ba1b33f
[deploy] Decouple Twitter authentication from fetching tweets (#7920)
* Add TwitterClient::Client

* Use TwitterClient::Client for Tweet

* Test retweets

* Test assignment to user

* Fix TweetTag spec

* Remove TwitterBot

* Fix some specs

* Fix RSS Reader specs
2020-05-19 18:05:41 -04:00
Dmitry Maksyoma
f63c7f9289
Fix Runkit tags not being activated when comment is added (#6767)
* Fix Runkit tags not being activated when comment is added

* Runkit tag activation was ran once, on page load. I've changed it to
  run on on comment preview and submit.
* It was necessary to add a check to skip already activated Runkit
  tags. The code didn't take into account that a tag could be already
  processed, and would just crash.

* Fix Runkit tags and add tests

* Add test for previewing article with Runkit tag

* "Fix CodeClimate not finding waitForRunkitAndActivateTags()

* Refactor a test for readability

* Make Rubocop happy

* Improve test for previewing article with Runkit tag

* Use one method for determining active Runkit tags

* Defer loading of JS from embed.runkit.com

* Add utility function dynamicallyLoadScript(url)

* Switch to dynamic loading of Runkit

* parsed content code block is also hidden now to avoid displaying <code /> block before runkit iframe loads.

* Fix Runkit test

* Remove Runkit script caching in v2 form

* Use <%== instead of .html_safe in v2 form

* Update app/assets/javascripts/utilities/dynamicallyLoadScript.js

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
2020-05-15 14:27:46 +02:00
Vaidehi Joshi
502bef156e
Allow an article's main_image to be removed (#5687) [deploy]
Currently, we don't allow users to remove the `main_image` of an article once it has been set. It can be changed, but never removed.
This change allows the `main_image` to be removed by checking for the `cover_image` key in the frontmatter that is sent along in the article's markdown. This means that a user should be able to remove the image associated with an article by removing the value of `cover_image:` from their frontmatter.
2020-03-10 08:29:59 -07:00
Mac Siri
8e4905522d
Implement KatexTag (#6237) [deploy]
* Install Katex gem

* Add Katex stylesheet and spec

* Implement basic error handling

* Remove comment

* Create more spec

* Update approval file

Changes is due to turning off RedCarpet's superscript feature

* Add instruction to _editor_guide_text

* Serve our own KaTeX css

* Apply Rhyme's suggestion

* Limit Katex's css use

* Update spec

* Add spec

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-03-09 17:58:54 -04:00
Anna Buianova
e09e46ec99 Creating podcasts by users (#3730) [deploy]
* Create podcast as a user [WIP]

* Sample css for podcast form

* Nicer podcasts suggesting form

* Validate podcast feed_url

* Validate podcast main_color_hex

* Fix podcasts specs

* Fix form appearance

* Placeholder for podcast main_color_hex

* Provide a link to suggest a podcast

* Add a checkbox and a role for when a podcast is added by an owner

* Prettier checkbox in the podcasts form

* Added creator to podcasts

* Set the podcast creator

* Fix the /pod spec

* Added creator information to the internal podcast page

* Added cta class to the podcasts submit button

* Global notice when a podcast was suggested

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-01-08 16:14:25 -05:00
rohan-techfreak
bf867a624a Add lazy loading to iframes (#4673) 2019-11-18 18:31:56 -05:00
rhymes
8989a52aba Strip EXIF and GPS data from uploaded images (#4450)
* Add specs for ArticleImageUploader

* Add specs for BadgeUploader

* Add specs for CoverImageUploader

* Add specs for ProfileImageUploader

* Refactor uploaders to inherit from BaseUploader

* Strip EXIF and GPS data from uploaded images

* Add ImageMagick to the docs

* Protect strip_exif
2019-10-24 16:35:10 -04:00
Mac Siri
dd391d5e34
Validates Article's published_at (#4140) 2019-10-01 15:57:36 -04:00
Bolarinwa Balogun
86b0777938 Set max file size limit for profile images (#3313) 2019-06-28 12:06:25 -04:00
Samyuktha J
74ecf5ca06 Make LinkTag's mininum reading time to 1 min (#3084) [ci skip] 2019-06-14 14:44:48 -04:00
rhymes
941ab4178b Articles API: create and update (#2844)
* Add system test to create article from the editor

* Move article creation from API to app controller

* Fix system test to edit posts

* Move article update from API to app controller

* Rewrite create article API using API key

* Add main_image and canonical_url to allowed creation params

* Rewrite update article API using API key

* Fix tests and have Comments API inherit from API
2019-05-16 12:26:24 -04:00
rhymes
3b4bda89df Upgrade Honeycomb gem, fix and improve RssReader tests (#2319)
* Switch from deprecated honeycomb-rails to honeycomb-beeline

* Improve error handling, tests and add refactoring

* Fix multiple fetching test and add one more

The test wasn't actually testing the correct behavior, because the class
by default force fetches. It worked because it wasn't reloading the user
from the database.

* Test that Honeycomb's client is doing its thing

* Use some defensive programming to avoid any possible problem during shutdown

* Fix typo

* Use the new API to add fields to the current measured event

* Use default instrumentation and add user info to event

* Replace user.email with user.username, less personal data around

* Use mocking instead of calling Honeycomb.init

* Freeze time before traveling

* Remove a flaky test dependent on rand
2019-04-07 15:27:53 -04:00
Mac Siri
f780e5fbc9 Refactor RssReader (#1537)
* Update RssReader::get_all_articles

* Move RssReader to services

* Create RssReader::Assembler

* Improve RssReader's spec
2019-01-14 14:25:49 -05:00