Open link in a new tab

Content

Expand project menu

Simple chat plugin

Hello OpenProject Community,

I am a beginner rails developer and I try to develope a simple chat plugin for OpenProject. I used

mickygingers walkthrough and adapted it to run as a plugin. 

What I have so far is a simple chat for all users on my OpenProject server. Here are some 

pictures of the rendered plugin:

(sorry for mixing languages (english + german) in the pictures)

My question is now.. How do I implement the ckeditor used by OpenProject instead of the simple form text_area.

The index.html.erb of the messages view looks like:

<%= form_for [@conversation, @message] do |f| %>
  <div class="custom-form">
    <div class="form-group">
    <%= f.text_area :body, autofocus: true, placeholder: "Your message", class: "form-control", rows: 5 %>
    </div>
    <%= f.button t(:send), class: 'button -highlight -with-icon icon-checkmark' %>
  </div>
<% end %>

<div id="conversation_messages">
  <% @conversation.conversation_messages.reverse_each do |message| %>
    <% if message.body %>
      <div class="media">
        <div class="media-left">
          <%= avatar(message.user) %> <strong> <%= message.user.name %> </strong> <%= message.message_time %>
        </div>
        <div class="media-body">
          <p><%= simple_format message.body %></p>
        </div>
      </div>
    <% end %>
  <% end %>
</div>

Thx, for the help.

--

Markus

Message actions

Hi Markus,

change your text_area as follows to add a class we use for positioning and use the with_text_formatting flag

    <%= f.text_area :body, class: 'wiki-edit', with_text_formatting: true, autofocus: true, placeholder: "Your message", class: "form-control", rows: 5 %>

That should be all!

Best,

Oliver

Message actions

Hey Oliver,

Thank you for your support. Your hint to use the with_text_formatting  flag was very good.

I had to change some more things to get it up and running. For every one who is interested, here the

new index.html.erb:

<%= labelled_tabular_form_for [@conversation, @message] do |f|%>
  <div class="custom-form">
    <%= f.text_area :body,
                    :cols => 80,
                    :rows => 5,
                    label: "&#8203;".html_safe,
                    container_class: '-xxwide',
                    with_text_formatting: true %>
  </div>
  <%= f.button t(:send), class: 'button -highlight -with-icon icon-checkmark' %>
  <hr class="form-separator">
<% end %>



<div id="conversation_messages">
  <% @conversation.conversation_messages.last(11).reverse_each do |message| %>
    <% if message.body %>
      <div class="media">
        <div class="media-left">
          <%= avatar(message.user) %> <strong> <%= message.user.name %> </strong> <%= message.message_time %>
        </div>
        <div class="media-body">
          <p><%= format_text message.body %></p>
        </div>
      </div>
    <% end %>
  <% end %>
</div>

I think this topic is now closed. Looks good to me (⌐■_■)

--

Markus

Message actions

Hello @Markus,
I wonder if you were able to have a working prototype for your plugin?
Will you publish it as open source?
Thank you,
  Timotheus

Message actions

Hello Timotheus,

I had a working prototype. But after the last update its not working
anymore. It is ok for me if you use my code, but I don't publish the
plugin, because I am not working on it anymore and its not ready
to be published.

Markus

Message actions

Hello Markus,
That would be great if you could send me the code to my email address: timotheus at pokorra.de
I have not worked with ruby before, but I would like to have a go at this challenge.
Thank you,
  Timotheus