docbrown/app/views/articles/_v2_form.html.erb
Anna Buianova ff76cdd3c5
Scheduling articles (#17939)
* Article query spec for scheduled articles

* Added scheduled article badge on the user dashboard

* Added published_at field to editor options

* Accept and validate published_at from editor

* Refactor published_at validation

* Allow 1-minute difference in published_at

* Notice on an unpublished article page

* Added specs for 'Click to edit' link on scheduled article preview page

* ContextNotification model

* Articles::Publish worker

* Added specs for articles publish worker

* Schedule publish articles worker

* Added tests to check for scheduled posts in feeds

* Don't allow managing scheduled articles

* Don't send notifications for scheduled articles

* Set published_at in Articles::Updater when publishing

* Published_at value in post options

* Pass timezone and set published_at accordingly

* Limit setting published_at to the future

* Readonly published_at for articles that were already published

* Chagning published_at format in editor v1 (start)

* Changed published_at format in frontmatter, specs

* Added specs for updating published_at from frontmatter

* Fixed accepting past published_at for articles published_from_feed

* Enabled published_at validation: don't allow updating published_at for already published articles

* Validate published_at on create

* Added a spec for updating published_at for exported articles

* Fixed specs related to creating articles with past published_at

* Fixed specs related to past published_at for articles

* Added a hack so that admins would be able to update published_at

* Switch button text schedule/publish when changin publishedAt

* Fixed saving published_at with timezone

* Added a feature flag for scheduling articles

* Default text in markdown editor depends on feature flag

* Enable article editor cache again

* Fixed the default value in the markdown editor

* Fix sitemaps spec

* Removed tooltip

* Fixed articles update specs

* Added missing locales

* Fixed article create specs

* Fixed spec

* Removed commented code

* Returned enabling extensions in the schema

* Returned accidentally deleted constraint

* Make articles query spec more stable

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>

* Removed commented code

* Removed unused code

* A clearer policy

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>

* Use StringInquirer for article current state

* Added a note and todo to articles factory past trait

* Remove duplicated PropType

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

* Refactor query in the Articles::PublishWorker

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

* Refactor articleForm.jsx

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

* Removed specs that are no longer relevant

* Removed useless onKeyUp on a hidden input

* Refactored articleForm

* Hide scheduling from post options when published_at is readonly

* Run sends notifications worker every 5 minutes instead of every minute

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-07-07 17:32:49 +03:00

110 lines
4.2 KiB
Text

<style>
body {
padding-top: 0 !important;
}
/* This weirdness below has a reason: https://github.com/forem/forem/pull/11701#issuecomment-737319289 */
.crayons-header,
.crayons-header * {
visibility: hidden;
position: absolute;
left: -9999em;
top: -9999em;
pointer-events: none;
opacity: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
}
.crayons-header .site-logo,
.crayons-header .site-logo * {
visibility: visible;
position: static;
pointer-events: auto;
opacity: 1;
clip: auto;
overflow: visible;
}
.crayons-footer {
display: none;
}
.wrapper {
overflow: unset;
}
</style>
<main id="main-content"
data-article="<%= article.to_json(only: %i[id title cached_tag_list published published_at body_markdown main_image organization_id canonical_url updated_at], methods: %i[series all_series]) %>"
data-organizations="<%= organizations&.to_json(only: %i[id name bg_color_hex text_color_hex], methods: [:profile_image_90]) %>"
data-version="<%= version %>"
data-site-logo='<%= render "layouts/logo" %>'
data-scheduling-enabled="<%= FeatureFlag.enabled?(:schedule_articles) %>">
<form class="crayons-article-form crayons-article-form--<%= version %>">
<div class="crayons-article-form__header">
<span class="crayons-article-form__logo">
<%= render "layouts/logo" %>
</span>
<div class="crayons-field__label">
<span class="hidden s:inline-block mr-2"><%= t("views.editor.create") %></span>
<% if organizations && organizations.size > 0 %>
<select name="article[organization_id]" id="article_publish_under_org" class="crayons-select w-auto mt-0">
<%= options_for_select({ "Personal" => "" }.merge(organizations.pluck(:name, :id).to_h), article.organization_id || "") %>
</select>
<% end %>
</div>
<nav class="crayons-article-form__tabs crayons-tabs ml-auto" aria-label="<%= t("views.editor.modes") %>">
<ul class="crayons-tabs__list">
<li>
<button data-text="Edit" class="crayons-tabs__item crayons-tabs__item--current" type="button" aria-current="page"><%= t("views.editor.edit") %></button>
</li>
<li>
<button data-text="Preview" class="crayons-tabs__item " type="button"><%= t("views.editor.preview") %></button>
</li>
</ul>
</nav>
<div class="crayons-article-form__close">
<a href="/" class="crayons-btn crayons-btn--ghost-dimmed crayons-btn--icon" title="<%= t("views.editor.close.title") %>">
<%= crayons_icon_tag(:x, title: t("views.editor.close.icon")) %>
</a>
</div>
</div>
<div class="crayons-card crayons-article-form__content">
<% if version == "v2" %>
<div class="text-padding">
<div class="crayons-article-form__cover" role="presentation">
<% if article.main_image.present? %>
<img src="<%= article.main_image %>" width="250" height="105" alt="Post cover" class="crayons-article-form__cover__image">
<% end %>
<button class="crayons-btn crayons-btn--outlined mr-2">
<label for="cover-image-input">
<% if article.main_image.present? %><%= t("views.editor.cover_image.change") %><% else %><%= t("views.editor.cover_image.add") %><% end %>
</label>
<input id="cover-image-input" type="file" accept="image/*" class="w-100 h-100 absolute left-0 right-0 top-0 bottom-0 overflow-hidden opacity-0 cursor-pointer" data-max-file-size-mb="25">
</button>
</div>
<div class="crayons-article-form__title">
<textarea class="crayons-textfield crayons-textfield--ghost fs-3xl m:fs-4xl l:fs-5xl fw-bold s:fw-heavy lh-tight" type="text" id="article-form-title" placeholder="<%= t("views.editor.new_title") %>" autocomplete="off"><%= article.title %></textarea>
</div>
</div>
<% end %>
</div>
</form>
</main>
<div class="hidden">
<%= render "pages/editor_markdown_help" %>
<%= render "pages/editor_liquid_help" %>
<%= render "pages/editor_frontmatter_help" %>
</div>
<script>
<%== RunkitTag.script %>
</script>