Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
uurcank committed Dec 8, 2021
1 parent bad0eaf commit 0f94ca1
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 205 deletions.
322 changes: 161 additions & 161 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,162 +1,162 @@
# HelpCenter

### 📖 Knowledge Base for your Ruby on Rails App

HelpCenter is a Rails wiki gem with Trix editor support for creating a knowledge base for your project. It includes categories, articles, simple moderation, the ability to leave comments to docs and more.

Out of the box, HelpCenter comes with styling for TailwindCSS 2.0 but you're free to customize the UI as much as you like by installing the views and tweaking the HTML.

## Requirements

```
Rails >= 6.1.4
```

## Installation

Before you get started, HelpCenter requires a `User` model in your application (for now).

Add this line to your application's Gemfile:

```ruby
gem 'help_center'
```

And then execute:

```bash
bundle
```

Install the migrations and migrate:

```bash
rails help_center:install:migrations
rails db:migrate
```

Add HelpCenter to your `User` model. The model **must** have `name` method which will be used to display the user's name on comments & discussions (if enabled). Currently only a model named `User` will work.

```ruby
class User < ActiveRecord::Base
include HelpCenter::SupportUser

def name
"#{first_name} #{last_name}"
end
end
```

Next add a `moderator` and `admin` flag to the `User` model.

```bash
rails g migration AddModeratorToUsers admin:boolean moderator:boolean
rails db:migrate
```
Only moderators or admins can manage articles.

```
if current_user.admin? || current_user.moderator?
```

Add the following line to your `config/routes.rb` file:

```ruby
mount HelpCenter::Engine => "/docs"
```

Add routes for active storage with your custom prefix

```ruby
get "/docs/rails/active_storage/blobs/:signed_id/*filename" =>
"active_storage/blobs#show"
get "/docs/rails/active_storage/representations/:signed_blob_id/:variation_key/*filename" =>
"active_storage/representations#show"
```

## Usage

To get all the basic functionality, the only thing you need to do is add a link to HelpCenter in your navbar.

```erb
<%= link_to "Docs", help_center_path %>
```

This will take the user to the views inside the Rails engine and that's all you have to do!

### Customizing

If you'd like to customize the views that HelpCenter uses, you can install the views to your Rails app:

```bash
rails g help_center:views
```

You can also install a copy of the HelpCenter controllers for advanced customization:

```bash
rails g help_center:controllers
```

Helpers are available for override as well. They are used for rendering the user avatars, text formatting, and more.

```bash
rails g help_center:helpers
```

**NOTE:** Keep in mind that the more customization you do, the tougher gem upgrades will be in the future.

### User comments & Notifications

You can enable user comments and questions for support articles. HelpCenter will attempt to send email and slack notifications for users who leave comments when a new reply posted.

To turn these off you can do the following in `config/initializers/help_center.rb`

```ruby
HelpCenter.setup do |config|
config.article_dicussions = false # Default: false
config.send_email_notifications = false # Default: true
config.send_slack_notifications = false # Default: true
end
```

Slack notifications require you to set `help_center_slack_url` in your `config/secrets.yml`. If you don't have this value set, it will not attempt Slack notifications even if they are enabled.


## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Roadmap / Upcoming features
Your support is appreciated for this project. Consider backing the project via GitHub Sponsors.

We plan to release following features:

- Contact form
- Built-in search
- Versioning Support
- Themes
- Dark Mode Support

## Acknowledgment

[simple_discussion](https://github.com/excid3/simple_discussion) by [Chris Oliver](https://github.com/excid3)

[Trix editor](https://github.com/basecamp/trix) by [Basecamp](https://github.com/basecamp)

[TailwindCSS](https://github.com/basecamp/trix) by [Tailwind Labs](https://github.com/tailwindlabs/tailwindcss)

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/uurcank/help_center This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

## Code of Conduct

# HelpCenter

### 📖 Knowledge Base for your Ruby on Rails App

HelpCenter is a Rails wiki gem with Trix editor support for creating a knowledge base for your project. It includes categories, articles, simple moderation, the ability to leave comments to docs and more.

Out of the box, HelpCenter comes with styling for TailwindCSS 2.0 but you're free to customize the UI as much as you like by installing the views and tweaking the HTML.

## Requirements

```
Rails >= 6.1.4
```

## Installation

Before you get started, HelpCenter requires a `User` model in your application (for now).

Add this line to your application's Gemfile:

```ruby
gem 'help_center'
```

And then execute:

```bash
bundle
```

Install the migrations and migrate:

```bash
rails help_center:install:migrations
rails db:migrate
```

Add HelpCenter to your `User` model. The model **must** have `name` method which will be used to display the user's name on comments & discussions (if enabled). Currently only a model named `User` will work.

```ruby
class User < ActiveRecord::Base
include HelpCenter::SupportUser

def name
"#{first_name} #{last_name}"
end
end
```

Next add a `moderator` and `admin` flag to the `User` model.

```bash
rails g migration AddModeratorToUsers admin:boolean moderator:boolean
rails db:migrate
```
Only moderators or admins can manage articles.

```
if current_user.admin? || current_user.moderator?
```

Add the following line to your `config/routes.rb` file:

```ruby
mount HelpCenter::Engine => "/docs"
```

Add routes for active storage with your custom prefix

```ruby
get "/docs/rails/active_storage/blobs/:signed_id/*filename" =>
"active_storage/blobs#show"
get "/docs/rails/active_storage/representations/:signed_blob_id/:variation_key/*filename" =>
"active_storage/representations#show"
```

## Usage

To get all the basic functionality, the only thing you need to do is add a link to HelpCenter in your navbar.

```erb
<%= link_to "Docs", help_center_path %>
```

This will take the user to the views inside the Rails engine and that's all you have to do!

### Customizing

If you'd like to customize the views that HelpCenter uses, you can install the views to your Rails app:

```bash
rails g help_center:views
```

You can also install a copy of the HelpCenter controllers for advanced customization:

```bash
rails g help_center:controllers
```

Helpers are available for override as well. They are used for rendering the user avatars, text formatting, and more.

```bash
rails g help_center:helpers
```

**NOTE:** Keep in mind that the more customization you do, the tougher gem upgrades will be in the future.

### User comments & Notifications

You can enable user comments and questions for support articles. HelpCenter will attempt to send email and slack notifications for users who leave comments when a new reply posted.

To turn these off you can do the following in `config/initializers/help_center.rb`

```ruby
HelpCenter.setup do |config|
config.article_dicussions = false # Default: false
config.send_email_notifications = false # Default: true
config.send_slack_notifications = false # Default: true
end
```

Slack notifications require you to set `help_center_slack_url` in your `config/secrets.yml`. If you don't have this value set, it will not attempt Slack notifications even if they are enabled.


## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Roadmap / Upcoming features
Your support is appreciated for this project. Consider backing the project via GitHub Sponsors.

We plan to release following features:

- Contact form
- Built-in search
- Versioning Support
- Themes
- Dark Mode Support

## Acknowledgment

[simple_discussion](https://github.com/excid3/simple_discussion) by [Chris Oliver](https://github.com/excid3)

[Trix editor](https://github.com/basecamp/trix) by [Basecamp](https://github.com/basecamp)

[TailwindCSS](https://github.com/basecamp/trix) by [Tailwind Labs](https://github.com/tailwindlabs/tailwindcss)

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/uurcank/help_center This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the HelpCenter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pasilobus/help_center/blob/master/CODE_OF_CONDUCT.md).
16 changes: 8 additions & 8 deletions app/views/shared/_admin_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% if current_user && (current_user.admin? || current_user.moderator?) %>
<div class="top-0 flex justify-between w-full z-50 bg-blue-600 text-purple-200 text-sm text-center font-brand-semibold px-4 py-3" role="alert">
<span class="text-base font-normal text-white">Welcome moderators (<%= current_user.email %>)</span>
<div>
<%= link_to t('add_an_article'), help_center.new_support_thread_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline mr-4 ml-6" %>
<%= link_to t('add_category'), help_center.new_support_category_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline" %>
</div>
</div>
<% if current_user && (current_user.admin? || current_user.moderator?) %>
<div class="top-0 flex justify-between w-full z-50 bg-blue-600 text-purple-200 text-sm text-center font-brand-semibold px-4 py-3" role="alert">
<span class="text-base font-normal text-white">Welcome moderators (<%= current_user.email %>)</span>
<div>
<%= link_to t('add_an_article'), help_center.new_support_thread_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline mr-4 ml-6" %>
<%= link_to t('add_category'), help_center.new_support_category_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline" %>
</div>
</div>
<% end %>
42 changes: 21 additions & 21 deletions app/views/shared/_sidebar_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div>
<% SupportCategory.sorted.each do |category| %>
<div data-controller="toggle" class="py-2 my-1 overflow-x-auto bg-white rounded shadow-inner-sm" data-toggle-open-value="<%= (@category.present? && @category == category) ? "true" : "false" %>">
<button class="mb-0 text-gray-700 font-medium text-base hover:text-gray-900" data-action="click->toggle#toggle">
<i class="fas fa-sort-down mr-2"></i>
<%= category.name %>
</button>
<div data-toggle-target="toggleable" class="<%= (@category.present? && @category == category) ? "" : "hidden" %>" >
<ul class="list-none leading-loose pl-6">
<% threads = SupportThread.where(support_category_id: category.id).order(:position) %>
<% threads.each do |thread| %>
<li>
<%= link_to help_center.support_thread_path(thread), class: "text-base font-normal text-gray-500 hover:text-gray-700" do %>
<%= thread.title %>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
<% end %>
<div>
<% SupportCategory.sorted.each do |category| %>
<div data-controller="toggle" class="py-2 my-1 overflow-x-auto bg-white rounded shadow-inner-sm" data-toggle-open-value="<%= (@category.present? && @category == category) ? "true" : "false" %>">
<button class="mb-0 text-gray-700 font-medium text-base hover:text-gray-900" data-action="click->toggle#toggle">
<i class="fas fa-sort-down mr-2"></i>
<%= category.name %>
</button>
<div data-toggle-target="toggleable" class="<%= (@category.present? && @category == category) ? "" : "hidden" %>" >
<ul class="list-none leading-loose pl-6">
<% threads = SupportThread.where(support_category_id: category.id).order(:position) %>
<% threads.each do |thread| %>
<li>
<%= link_to help_center.support_thread_path(thread), class: "text-base font-normal text-gray-500 hover:text-gray-700" do %>
<%= thread.title %>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
<% end %>
</div>
Loading

0 comments on commit 0f94ca1

Please sign in to comment.