Skip to content

Commit

Permalink
DEV: Clean up the plugin (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX authored Aug 1, 2023
1 parent 6309490 commit 6761e2c
Show file tree
Hide file tree
Showing 76 changed files with 1,101 additions and 1,048 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.DS_Store
gems/
/node_modules
.on-save.json
node_modules
yarn-error.log
.rubocop-https---raw-githubusercontent-com-discourse-*
/gems
/auto_generated
2 changes: 1 addition & 1 deletion .streerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--print-width=100
--plugins=plugin/trailing_comma
--plugins=plugin/trailing_comma,disable_ternary
--ignore-files=vendor/*
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ source "https://rubygems.org"
group :development do
gem "rubocop-discourse"
gem "syntax_tree"
gem "syntax_tree-disable_ternary"
end
46 changes: 29 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,54 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.6.2)
parallel (1.22.1)
parser (3.1.2.1)
json (2.6.3)
language_server-protocol (3.17.0.3)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
prettier_print (1.2.0)
racc
prettier_print (1.2.1)
racc (1.7.1)
rainbow (3.1.1)
regexp_parser (2.6.0)
rexml (3.2.5)
rubocop (1.36.0)
regexp_parser (2.8.1)
rexml (3.2.6)
rubocop (1.55.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-discourse (3.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-discourse (3.3.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-rspec (2.13.2)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
ruby-progressbar (1.11.0)
syntax_tree (5.1.0)
rubocop-rspec (2.23.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
syntax_tree (6.1.1)
prettier_print (>= 1.2.0)
unicode-display_width (2.3.0)
syntax_tree-disable_ternary (1.0.0)
unicode-display_width (2.4.2)

PLATFORMS
ruby

DEPENDENCIES
rubocop-discourse
syntax_tree
syntax_tree-disable_ternary

BUNDLED WITH
2.1.4
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
## Discourse Calendar
# Discourse Calendar

Adds the ability to create a dynamic calendar in the first post of a topic.

Topic discussing the plugin itself can be found here: [https://meta.discourse.org/t/discourse-calendar/97376](https://meta.discourse.org/t/discourse-calendar/97376)

### Customisation
## Customization

#### Plugins

##### Events
### Events

- `discourse_post_event_event_will_start` this DiscourseEvent will be triggered one hour before an event starts
- `discourse_post_event_event_started` this DiscourseEvent will be triggered when an event starts
- `discourse_post_event_event_ended` this DiscourseEvent will be triggered when an event ends

#### Custom Fields
### Custom Fields

Custom fields can be set in plugin settings. Once added a new form will appear on event UI.
These custom fields are available when a plugin event is triggered.

#### Holidays
### Holidays

See an incorrect or missing holiday? Familiarize yourself with the [holiday definition Syntax](vendor/holidays/definitions/doc/SYNTAX.md). Then make your updates in the `vendor/holiday/definitions` directory.

Generate updated holidays as follows.

```sh
cd vendor/holidays

# Generate holiday definitions
bundle exec rake generate:definitions
bin/rails generate:definitions
```

Install the plugin and switch to the discourse root(not the plugin directory).

```sh
# Collect all holiday regions into assets/javascripts/lib/regions.js
bundle exec rake javascript:update_constants
bin/rails javascript:update_constants
```
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AdminHolidaysListItem
@holiday={{holiday}}
@isHolidayDisabled={{holiday.disabled}}
@region_code={{region_code}}
@region_code={{@region_code}}
/>
{{/each}}
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion assets/javascripts/discourse/components/region-input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed } from "@ember/object";
import { HOLIDAY_REGIONS } from "discourse/plugins/discourse-calendar/lib/regions";
import { HOLIDAY_REGIONS } from "../lib/regions";
import I18n from "I18n";
import ComboBoxComponent from "select-kit/components/combo-box";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Promise } from "rsvp";
import { isNotFullDayEvent } from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import { formatEventName } from "discourse/plugins/discourse-calendar/helpers/format-event-name";
import { isNotFullDayEvent } from "../lib/guess-best-date-format";
import { formatEventName } from "../helpers/format-event-name";
import loadScript from "discourse/lib/load-script";
import Component from "@ember/component";
import { schedule } from "@ember/runloop";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { action } from "@ember/object";
import { TIME_ZONE_TO_REGION } from "discourse/plugins/discourse-calendar/lib/regions";
import { TIME_ZONE_TO_REGION } from "../../lib/regions";

export default {
setupComponent(args, component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { action, computed, set } from "@ember/object";
import { equal, gte } from "@ember/object/computed";
import { extractError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service";
import { buildParams, replaceRaw } from "../../lib/raw-event-helper";
import { buildParams, replaceRaw } from "../lib/raw-event-helper";

const DEFAULT_REMINDER = {
type: "notification",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import guessDateFormat from "../lib/guess-best-date-format";
import { htmlHelper } from "discourse-common/lib/helpers";

export default htmlHelper((date) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import eventRelativeDate from "discourse/plugins/discourse-calendar/lib/event-relative-date";
import eventLocalDate from "discourse/plugins/discourse-calendar/lib/event-local-date";
import eventRelativeDate from "../lib/event-relative-date";
import eventLocalDate from "../lib/event-local-date";

function initializeDecorateTopicTitle(api) {
api.decorateTopicTitle((topic, node, topicTitleType) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import { ajax } from "discourse/lib/ajax";
import Category from "discourse/models/category";
import I18n from "I18n";
import {
colorToHex,
contrastColor,
stringToColor,
} from "discourse/plugins/discourse-calendar/lib/colors";
import { colorToHex, contrastColor, stringToColor } from "../lib/colors";
import { createPopper } from "@popperjs/core";
import { isNotFullDayEvent } from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import { formatEventName } from "discourse/plugins/discourse-calendar/helpers/format-event-name";
import { isNotFullDayEvent } from "../lib/guess-best-date-format";
import { formatEventName } from "../helpers/format-event-name";
import getURL from "discourse-common/lib/get-url";

function loadFullCalendar() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import I18n from "I18n";
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import guessDateFormat from "../lib/guess-best-date-format";
import { cookAsync } from "discourse/lib/text";
import WidgetGlue from "discourse/widgets/glue";
import { getRegister } from "discourse-common/lib/get-owner";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isTesting } from "discourse-common/config/environment";
import { cancel } from "@ember/runloop";
import eventRelativeDate from "discourse/plugins/discourse-calendar/lib/event-relative-date";
import eventRelativeDate from "../lib/event-relative-date";
import discourseLater from "discourse-common/lib/later";

function computeRelativeEventDates() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import guessDateFormat from "./guess-best-date-format";

export default function eventLocalDate(container) {
container.classList.remove("past", "current", "future");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import I18n from "I18n";
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
import guessDateFormat from "./guess-best-date-format";

function _computeCurrentEvent(container, endsAt) {
const indicator = document.createElement("div");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hbs from "discourse/widgets/hbs-compiler";
import { createWidget } from "discourse/widgets/widget";
import roundTime from "discourse/plugins/discourse-calendar/lib/round-time";
import roundTime from "../lib/round-time";

export default createWidget("discourse-group-timezones-time-traveler", {
tagName: "div.group-timezones-time-traveler",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hbs from "discourse/widgets/hbs-compiler";
import { createWidget } from "discourse/widgets/widget";
import roundTime from "discourse/plugins/discourse-calendar/lib/round-time";
import roundTime from "../lib/round-time";

export default createWidget("discourse-group-timezones", {
tagName: "div.group-timezones",
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/discourse/widgets/discourse-post-event.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import I18n from "I18n";
import TextLib, { emojiUnescape } from "discourse/lib/text";
import { exportEntity } from "discourse/lib/export-csv";
import cleanTitle from "discourse/plugins/discourse-calendar/lib/clean-title";
import cleanTitle from "../lib/clean-title";
import { dasherize } from "@ember/string";
import EmberObject from "@ember/object";
import showModal from "discourse/lib/show-modal";
import hbs from "discourse/widgets/hbs-compiler";
import { createWidget } from "discourse/widgets/widget";
import { routeAction } from "discourse/helpers/route-action";
import { buildParams, replaceRaw } from "../../lib/raw-event-helper";
import { buildParams, replaceRaw } from "../lib/raw-event-helper";
import { escapeExpression } from "discourse/lib/utilities";

export default createWidget("discourse-post-event", {
Expand Down
6 changes: 3 additions & 3 deletions assets/stylesheets/common/discourse-calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
.fc-list-item-add-to-calendar {
color: var(--tertiary);
font-size: $font-down-1;
font-size: var(--font-down-1);
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ a.holiday {
align-items: center;
justify-content: space-between;
color: inherit;
font-size: $font-down-1;
font-size: var(--font-down-1);

.before {
margin-right: auto;
Expand Down Expand Up @@ -358,7 +358,7 @@ a.holiday {
}

.offset {
font-size: $font-down-2;
font-size: var(--font-down-2);
margin-left: 0.5em;
}
}
Expand Down
4 changes: 2 additions & 2 deletions assets/stylesheets/common/discourse-post-event-builder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

.name {
font-size: $font-down-1;
font-size: var(--font-down-1);
}

&.from {
Expand Down Expand Up @@ -69,7 +69,7 @@
border: 0;

.name {
font-size: $font-down-1;
font-size: var(--font-down-1);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions assets/stylesheets/common/discourse-post-event-core-ext.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.event-date {
display: inline-flex;
align-items: center;
font-size: $font-down-2;
font-size: var(--font-down-2);
border: 1px solid var(--primary-medium);
background: none;
padding: 0 0.25em;
Expand All @@ -30,7 +30,7 @@

.header-title {
.event-date {
font-size: $font-down-4;
font-size: var(--font-down-4);
color: var(--primary-medium);
font-weight: normal;
padding: 0.25em;
Expand Down
8 changes: 4 additions & 4 deletions assets/stylesheets/common/discourse-post-event.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ $interested: #fb985d;
.month {
text-align: center;
color: red;
font-size: $font-down-1;
font-size: var(--font-down-1);
text-transform: uppercase;
}

.day {
text-align: center;
font-weight: 500;
font-size: $font-up-2;
font-size: var(--font-up-2);
}
}

Expand All @@ -111,7 +111,7 @@ $interested: #fb985d;
display: flex;
align-items: center;
color: var(--primary-medium);
font-size: $font-down-1;
font-size: var(--font-down-1);
margin: 0.25em 0;

.separator {
Expand Down Expand Up @@ -253,7 +253,7 @@ $interested: #fb985d;
border: 1px solid var(--primary-low);

.d-icon {
font-size: $font-down-3;
font-size: var(--font-down-3);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/stylesheets/common/upcoming-events-calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
}
.fc-list-item-add-to-calendar {
color: var(--tertiary);
font-size: $font-down-1;
font-size: var(--font-down-1);
}
}
Loading

0 comments on commit 6761e2c

Please sign in to comment.