HTML Parser in Editor

Now Think of an editor which can show output as well. Sounds amazing? what if Instantly we get the output of whatever we write or code in any language. This seems to be an amazing task so let’s do it!

Let’s start from HTML

whatever we write using HTML tags immediately we get output in the browser. Their are multiple ways to do that but we are lazy one :p . So, let’s do in a simpler way.

Now Think how we can do this?

let me tell you, we just have to open the html file using a tag and show it into new tab simple. Now let’s be more technical.

First, create an a tag with attribute target=”_blank”

target=”_blank”- This will open the file in new tab

now Javascript

  $(“.compile”).attr(‘href’,”location”);

I just added the attribute href dynamically with location of the file;

location is like “uploads/extract/:id/:upload_file_name”

and it redirects at https://localhost:3000/uploads/extract/1/file

then how routes will configure public path? Because all the project is store in public folder

For this

edit routes in config/routes.rb

get ‘uploads/extract/:id/:upload_file_name(*all)’, to: ‘gitrepos#moveto’

it will go to controller gitrepos and action moveto

def moveto
goto = {}
request.path_parameters.each do |key, value|
goto[key] = value
end
path = “/system/repositories/github/#{goto[:id]}/#{goto[:url]}#{goto[:all]}”
redirect_to(path)
end

That’s it!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s