Quantcast
Channel: Discourse Meta - Latest topics
Viewing all 60721 articles
Browse latest View live

Synchronising log out of discourse when logging out of WordPress

$
0
0

@Nick_Putman wrote:

Hi,

I am using the Wordpress plugin for discourse, and I am wondering if there is a way of synchronising the logouts, as well as the logging in, to make things simpler for users.

At present, as I understand it, once users are logged in to the Wordpress site they can then navigate to the discourse forum, but have to click Login again - it would be simpler if this wasn't necessary.

Also, it seems that logging out of either Wordpress or discourse doesn't also log the user out of the other account. Would it be possible to implement this?

Thanks,

Nick

Posts: 14

Participants: 2

Read full topic


Creating Routes in Discourse and Showing Data

$
0
0

@eviltrout wrote:

Over time Discourse has grown in complexity and it can be daunting for beginners to understand how data gets all the way from the back end Ruby on Rails application to the Ember.js application in front.

This tutorial is meant to show the full lifecycle of a request in Discourse and explain the steps necessary if you want to build a new page with its own URL in our application.

URLs First

I always prefer to start thinking of features in terms of the URLs to access them. For example let’s say we want to build an admin feature that showed the last snack I ate while working on Discourse. A suitable URL for that would be /admin/snack

In this case:

  • Visiting /admin/snack in your browser should show the snack using the “full stack”, in other words the Ember application will be loaded up and it would request the data it needs to display the snack.

  • Visiting /admin/snack.json should return the JSON data for the snack itself.

The Server Side (Ruby on Rails)

Let’s start by creating a new controller for the snack.

app/controllers/admin/snack_controller.rb

class Admin::SnackController < Admin::AdminController

  def index
    render json: { name: "donut", description: "delicious!" }
  end

end

In this case we inherit from Admin::AdminController to gain all the security checks to make sure the user viewing the controller is an administrator. We just have one more thing to do to before we can access our controller, and that’s to add a line to config/routes.rb:

Find the block that looks like this:

namespace :admin, constraints: StaffConstraint.new do
  # lots of stuff
end

And add this line inside it:

get 'snack' => 'snack#index'

Once you’re done, you should be able to visit /admin/snack.json in your browser and you’ll see JSON for the snack! Our snack API seems to be working :candy:

Of course, as you build your feature to add more complexity you likely wouldn’t just return hardcoded JSON from a controller like this, you’d query the database and return it that way.

The Client Side (Ember.js)

If you open up your browser and visit /admin/snack (without the .json) you’ll see that Discourse says “Oops! That page doesn’t exist.” — that’s because there’s nothing in our front end Ember application to respond to the route. Let’s add a handlebars template to show our snack:

app/assets/javascripts/admin/templates/snack.hbs

<h1>{{model.name}}</h1>

<hr>

<p>{{model.description}}</p>

And, like on the Rails API side we need to wire up the route. Open the file app/assets/javascripts/admin/routes/admin-route-map.js.es6 and look for the map() method. Add the following line:

this.route(‘snack’);

We have one final thing left to do in Ember land, and that’s to have the Ember application perform an AJAX request to fetch our JSON from the server. Let’s create one last file. This will be an Ember Route. Its model() function will be called when the route is entered, so we’ll make our ajax call in there:

app/assets/javascripts/admin/routes/admin-snack.js.es6

import { ajax } from 'discourse/lib/ajax';

export default Ember.Route.extend({
  model() {
    return ajax('/admin/snack.json');
  }
});

Now, you can open your browser to /admin/snack and you should see the details of the snack rendered in the page!

Summary

  • Opening your browser to /admin/snack boots up the Ember application

  • The Ember application router says snack should be the route

  • The Ember.Route for snack makes an AJAX request to /admin/snack.json

  • The Rails application router says that should be the admin_snack controller

  • The admin_snack_controller returns JSON

  • The Ember application gets the JSON and renders the Handlebars template

Where to go from here

I'm going to be adding two more tutorials in this series. One which adds an Ember Component to the template, and one that adds tests for everything. Those are coming soon!

Posts: 1

Participants: 1

Read full topic

Discourse for Online Education Communities

$
0
0

@erlend_sh wrote:

Originally published at: http://blog.discourse.org/2016/08/discourse-for-online-education-communities/
Just like our survey for game communities back in May, we once more sent out a survey to a mix of customers and self-supported Discourse communities. This time we wanted feedback from leaders in online education. We’re absolutely ecstatic about the amount of learning tools readily available online for young and old minds alike today.…

Posts: 1

Participants: 1

Read full topic

Built in spell and grammar checker

$
0
0

@Konstantin_Ladutenko wrote:

Hi,

I recently had an amazing writing experience using TeXstudio with a spell and grammar check done in real time (via Language Tool app installed locally). It is very useful if you are more focused on the subject and facts and less on the grammar and style. This is especially true if you are writing in some non-native language. Even simple checks like avoid word repetition and common typos not detected with speller are very helpful (a good example is “My English is very bed”). And this is not only about writing, a well-written text can provide a pleasure for a reader, a crappy one leads to annoyance.

There is a number of plugins aimed to do this for online writing. I am actually using one at the moment, however, it is a bit buggy on providing corrections for mistakes. The major drawback is that it is only for English.

Langage Tool is a Java app that can be run in server mode, and used via JSON API. Moreover, you can use your own instance (it is open sourced) or use the service they provide on web site. It has enough performance to check 400.000 sentences in about 4 minutes on my dual-core laptop, so it should not stack even under heavy traffic. As far as I know it is the best multilingual grammar checker, even more - it is relatively easy to contribute new rules for your native language to detect your favorable typos.

So, using a smart spell and grammar checker is a great pleasure, which can be provided to every Discourse post writer via integration with Language Tool (or any other app, probably you can find out a better possibility). Any ideas about implementation? Is it interesting enough to be added into Discource developers' todo list?

Kostya

Posts: 4

Participants: 3

Read full topic

Inline code blocks in code fence mode

$
0
0

@dfabulich wrote:

In the default mode of the code </> button, when you select some text in the middle of a line and click the code button, it wraps that text in single backticks, like `this`.

We learned about the "code formatting style = code-fences" mode from today's blog post and turned it on right away, but I was surprised to find that selecting a word inline and clicking the code button no longer wraps it in single backticks; it wraps it in triple backticks and adds newlines before and after the selected word.

Users can delete the newlines to get the intended result (which is to say, you can write ```triple backticks``` on a single line and it DTRT) but I don't think it's correct to add newlines to selected text.

This is a bug, right? (Or is it by design for some reason?)

Posts: 2

Participants: 2

Read full topic

Discourse email delivery rejected with cPanel SMTP server

$
0
0

@Avaruusromu wrote:

I've installed Discourse on a VPS running cPanel. Forum site seem to work properly but all emails sent by it gets rejected and not delivered by the default mail server of cPanel. The following is a screen capture of delivery report (from cPanel WHM) of Discourse generated email:

The configuration is typical and I can't spot any problem there:

DISCOURSE_DEVELOPER_EMAILS: 'XXXXX@YYYYYYY.com'
DISCOURSE_SMTP_ADDRESS: smtp.YYYYYYY.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: XXXXX@YYYYYYY.com
DISCOURSE_SMTP_PASSWORD: qwertyui
DISCOURSE_SMTP_ENABLE_START_TLS: false

Also /var/discourse/shared/standalone/log/rails/production.log shows no errors when sending email:

Sent mail to XXXXX@YYYYYYY.com (947.2ms)

I've also tested how wrong password would look like (just to exclude that possibility):

Sent mail to XXXXX@YYYYYYY.com (2130.2ms)
Job exception: 535 Incorrect authentication data

So the only problem is the rejection of the message in email server side. Any ideas what could cause this? The SMTP of my VPS works very well with exact same settings when I'm sending mail with Thunderbird.

Thanks!

Posts: 4

Participants: 2

Read full topic

Image URLs not rendered as images on import

$
0
0

@pfaffman wrote:

I've written an importer for a custom database of external images. It's based on import_scripts/vanilla_mysql.rb (and base.rb) (pulled just today). It's creating posts that look good right to me (a few problems with categories yet to work out). Posts have lines like

http://example.com/veryFineImage.jpb

in them.

  • When I look at them the URL isn't displaying the image.
  • If I edit the image, it shows the image in the preview window.
  • If I edit and add a space anywhere in the post the image is displayed as expected.

"No problem!" thinks me "just rebake the posts. I do a

bundle exec rake rebake

on my development box. It rebakes the posts Or so it claims!!!!

But, no joy. The image urls still just show up as urls.

On a related note, once I figure this out, will Discourse pull those images to it's local store like it normally does? Do I need to do anything to force it to do it to all of them? I don't see any obvious thing to poke in sidekiq.

Posts: 4

Participants: 2

Read full topic

Deleted post text appearing in activity summaries

$
0
0

@jesselperry wrote:

I am a member of the Squarespace Circle Discourse site and get daily activity summary emails.

I just noticed that activity summary emails include deleted posts' text: (post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

I would imagine that should be excluded from being listed as a post in the summary? Or should it stay since as of when the activity summary was sent, that post was still there?

Posts: 2

Participants: 2

Read full topic


"This site can’t be reached"

$
0
0

@auryn_macmillan wrote:

Continuing the discussion from Connection Refused after DigitalOcean Droplet Upgrade?:

I've just finished a the setup of a new discourse instance on a fresh server running ubuntu 16.04, but for some reason I can't seem to access the site in a browser ("This site can’t be reached" error in chrome) nor is the server returning pings (100% packet loss).

docker stats app shows the app running, and I have tried both restarting docker and rebooting the machine with no luck.

I have no issues using SSH to log in to the server remotely. Any help would be greatly appreciated.

Posts: 3

Participants: 2

Read full topic

Discourse Update Failed - Rebuild Now Fails

$
0
0

@Sisko wrote:

I was updating my Discourse but it was taking a long time so i left it over night, the following morning it had not moved so i cancelled it.

I am using Docker so I attempted to start the container, it starts up but has a 502 Bad Gateway error.

Attempts to rebuild have not gone well, it fails attempting to run "gem update bundler" with the error

ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
timed out (https://api.rubygems.org/specs.4.8.gz)

The main failure message has some more information


FAILED

Pups::ExecError: cd /var/www/discourse && gem update bundler failed with return #
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"web", "cmd"=>["gem update bundler", "chown -R discourse $home"]}
3d9e6b7b840aef42b0b45e17f09013769ed7af4f46fffe40d2e2049b7b102616
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one


I have tried to use alternate sources for the Gem and have even tried adding the china template to my app.yml but i still receive the same error.

I am able to enter the container and manually run "gem update bundler" but it says that there is nothing to update.


root@server1:/var/discourse# ./launcher enter app
root@server1-app:/# gem update bundler
Updating installed gems
Nothing to update


I have a feeling that there are other issues causing the problem.

The full rebuild log can be found here.

Reading through the logs i have found that there are a few errors with postgresql that might be related, however i am not sure as i havent read through a successful rebuild log. I originally had some screenshots of the errors but as a new user i cant post them....

Some errors are about the database already existing and another is about failing to bind to the port because its already in use even though a few lines before it successfully bound to the port. This may be normal behaviour but i thought id mention it just in case.

The server definitely has enough RAM (32GB) and enough storage space.

Posting here is my last resort before i decide to scrap the whole thing and install a fresh copy.

I can provide more information if required.

Any help will be much appreciated!

Regards,
Sisko

P.S This post was formatted much nicer to begin with but for some reason new users arent allowed to post more than 2 links an 1 image...

Posts: 7

Participants: 2

Read full topic

Welcome messages should be marked as read for the sender

$
0
0

@barryvan wrote:

I've set up Discourse so that the welcome messages come from my user -- and I've made them a little more personal to match. :slight_smile: I note, though, that all of these messages are considered "unread" for me. Would it not make more sense for them to be marked as read by default, unless and until someone replies?

Strangely, they don't show up in my "sent" folder -- but they do show up in "Suggested messages" when I'm reading other messages.

(I'm not convinced by the utility of "suggested messages", but that's a discussion for another time!)

Posts: 1

Participants: 1

Read full topic

Troubleshooting multi-site databases

$
0
0

@Hammad_Abbasi wrote:

Hi,

I have setup a multi-site up and running however I am unable to create admin or configure notification email for 2nd site
so i have few questions

How can i configure SiteSettings in app.yml for a) 2nd Site b) ALL SITES
- exec: rails r "SiteSetting.notification_email=''"

I have tried manually connecting to both databases using
sudo -u postgres psql b_discourse
but when i run select * from users ( it returns nothing )

I tried running "rake admin:create RAILS_DB=b_discourse"- but this is creating the user on first site.

I ran "SiteSetting.notification_email" command in rails console it shows email from 1st Site - is there any way i can switch database in rails console ?

Posts: 3

Participants: 2

Read full topic

Undefined local variable or method `e' during phpbb3 migration

$
0
0

@mbajur wrote:

During a phpbb3 migration, for one of the posts, importer throws:

28291 / 1126938 (  2.5%)  [583509 items/min]  /var/www/discourse/script/import_scripts/phpbb3/support/text_processor.rb:56:in `rescue in bbcode_to_md': undefined local variable or method `e' for #<ImportScripts::PhpBB3::TextProcessor:0x007f41aa627198> (NameError)
        from /var/www/discourse/script/import_scripts/phpbb3/support/text_processor.rb:54:in `bbcode_to_md'

FYI: i've been following an official docker-based migration guide.


Edit: I've been able to fix this by editing the #bbcode_to_md method to:

def bbcode_to_md(text)
  begin
    text.bbcode_to_md(false)

  # Added `=>` below
  rescue => e
    puts "Problem converting \n#{text}\n using ruby-bbcode-to-md"
    text
  end
end

Posts: 5

Participants: 3

Read full topic

Restoring backup locally doesn't work

$
0
0

@jamesmarkcook wrote:

I must be doing something wrong; I'm running a local instance of Discourse and attempted to restore a backup of a production site. Once the backup restore completes, it tells me it was successful, but my site is still empty. Any ideas?

Posts: 1

Participants: 1

Read full topic

Search in private massages when you hit enter

$
0
0

@BlackSheep wrote:

I have a very active user that says he can't never find anything in his private messages. He is not very computer-wise and i was sceptic, I have never had this problem but in the end I have been able to track the problem down.

If you do a search in your inbox waiting for the dropdown menu with the results everything works fine:
<-message found

But the moment you hit enter (as this user always does) it always sends you to an empty page with no results:

So that's why this user says the inbox search is not working. It is a very minor bug with no importance, I just wanted to notify it.

Posts: 1

Participants: 1

Read full topic


Migrating from bbPress WordPress plugin to Discourse

$
0
0

@vinothkannans wrote:

I recently did a bbPress database migration successfully using Discourse's inbuilt migration script. Now I'm going to share it as a step-by-step tutorial.

Note: This tutorial is for the bbPress plugin, not the legacy standalone version of bbPress.

What data can be imported?

  • Users
  • Categories
  • Topics
  • Posts

Before starting the migration set a development environment on your machine (or inside a virtual machine) and run the import there instead of inside the docker container. When I tried it inside docker container I got peer authentication failed issue. So I strongly recommending you that you use a development machine. See the OS X or Ubuntu installation guide for development.

I used Ubuntu 16.04 LTS amd64 xenial image. I recommending using Ruby version 2.3.0 or above (at least 2.0.0). Because I had some compatability issues when installing mysql2 with older versions of Ruby.

To check Ruby version enter the command below

ruby -v

Now we need mysql2 gem for ruby to connect with our old bbPress forum's WordPress database. Run the below commands to install libmysqlclient-dev dependency & mysql2 gem.

sudo apt-get install libmysqlclient-dev
gem install mysql2

After the successful installation go to your Discourse installation path and open Gemfile to edit.

cd ~/discourse
sudo nano Gemfile

Now insert the line below at the end of the file to add mysql2 gem to Discourse.

gem 'mysql2'

Open bbPress import script file to edit.

sudo nano script/import_scripts/bbpress.rb

In this file you can find the mysql database connection code below

    @client = Mysql2::Client.new(
      host: "localhost",
      username: "root",
      database: BB_PRESS_DB,
    )

By default the database host is localhost and username is root.

If you are migrating your database from localhost you don't need to change these settings (in most cases). You have to change the database name only.

Database name is retrieved from ENV variable. You can check it in top of the ruby file. So you can set it in ~/discourse/.env file or just edit the name database attribute like below. I prefer second method :stuck_out_tongue:

    @client = Mysql2::Client.new(
      host: "localhost",
      username: "root",
      database: "my_bbpress",
    )

If you are migrating your database from external server then you have to add password attribute to database settings. I am going to simply add raw password in the Ruby file directly. You may add it in .env file and use it here like database name. So after password inclusion your mysql database setting should look like below.

    @client = Mysql2::Client.new(
      host: "REMOTE_HOST_NAME",
      username: "DB_USERNAME",
      password: "MY_SECURE_PASSWORD",
      database: "DB_NAME",
    )

Now save the file and exit. It's time to run migration script :open_mouth:

Run the command below in your discourse installation path.

bundle exec ruby script/import_scripts/bbpress.rb

Congratulations! Your database successfully migrated from bbPress to Discourse :clap: :wave: :boom:

Now take a backup from admin page /admin/backups and import it in your live Discourse website.


After you moved your bbPress forum to Discourse if you are still going to use your WordPress website as primary site and you'd like to connect it with Discourse then install Discourse's official WordPress plugin.

Posts: 1

Participants: 1

Read full topic

Changing the home page

$
0
0

@Demerzel wrote:

Hello, why this change on the home page? the old format was fine. The right column was fine, with three or four lines which showed the latest topics of EVERY categories. How to find the old format. Thank you

Posts: 4

Participants: 3

Read full topic

Where is the Group Page?

$
0
0

@jamesmarkcook wrote:

I've been searching the forum and keep seeing reference to Group Pages but can't actually see a Groups link or anything in my Discourse or this one.

I've created a Group and made it public. Where can I find it?

Posts: 4

Participants: 3

Read full topic

Adding Ember Components to Discourse

$
0
0

@eviltrout wrote:

In the previous tutorial I showed how to configure both the server and the client side parts of Discourse to respond to a request.

In this tutorial, I’m going to create a new Ember Component as a way to wrap third party Javascript. This is going to be similar to a YouTube video I made a while back, which you may find informative, only this time it’s specific to Discourse and how we lay out files in our project.

Why Components?

Handlebars is quite a simple tempting language. It’s just regular HTML along with some dynamic parts. This is simple to learn and great for productivity, but not so great for code re-use. If you’re developing a large application like Discourse, you’ll find that you want to re-use some of the same things over and over.

Components are Ember’s solution to this problem. Let’s create a component that will display our snack in a nicer way.

Creating a new Component

Components need to have a dash in their name. I’m going to choose fancy-snack as the name for this one. Let’s create our template:

app/assets/javascripts/admin/templates/components/fancy-snack.hbs

<div class='fancy-snack-title'>
  <h1>{{snack.name}}</h1>
</div>

<div class='fancy-snack-description'>
  <p>{{snack.description}}</p>
</div>

Now, to use our component, we will replace our existing admin/snack template with this:

app/assets/javascripts/admin/templates/snack.hbs

{{fancy-snack snack=model}}

We can now re-use our fancy-snack component in any other template, just passing in the model as required.

Adding Custom Javascript Code

Besides re-usability, Components in Ember are great for safely adding custom Javascript, jQuery and other external code. It gives you control of when the component is inserted into the page, and when it is removed. To do this, we define an Ember.Component with some code:

app/assets/javascripts/admin/components/fancy-snack.js.es6

export default Ember.Component.extend({
  didInsertElement() {
    this._super();
    this.$().animate({ backgroundColor: "yellow" }, 2000);
  },

  willDestroyElement() {
    this._super();
    this.$().stop();
  }
});

If you add the above code and refresh the page, you’ll see that our snack has an animation of a slowly fading yellow background.

Let’s explain what’s going on here:

  1. When the component is rendered on the page it will call didInsertElement

  2. The first line of didInsertElement (and willDestroyElement) is this._super() which is necessary because we’re subclassing Ember.Component.

  3. The animation is done using jQuery’s animate function.

  4. Finally, the animation is cancelled in the willDestroyElement hook, which is called when the component is removed from the page.

You might wonder why we care about willDestroyElement at all; the reason is in a long lived Javascript application like Discourse it’s important to clean up after ourselves, lest we leak memory or leave things running. In this case we stop the animation, which tells any jQuery timers that they needn’t fire any more as the component is no longer visible on the page.

Where to go from here

I’ll be adding a final tutorial in this series about how to write tests for all this new functionality we’ve added!

Posts: 1

Participants: 1

Read full topic

Creating a "member-only/invite" thread?

Viewing all 60721 articles
Browse latest View live




Latest Images