Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixbug #11 and add a new option --json #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cpaper
Copy link

@cpaper cpaper commented Oct 8, 2019

  1. Fixbug New Visual ouput feature not working on Chrome and Safari #11 : use erb template to generate the HTML file and feed data into it as embedded JavaScript
    修复bug New Visual ouput feature not working on Chrome and Safari #11 : JavaScript跨域问题。
    使用Ruby erb模板生成HTML文件,并将数据以JSON格式插入;在HTML中被解释为JS代码,避免了跨域请求数据。

  2. output in JSON format by adding a option --json
    增加一个选项 --json,输出格式为 JSON

@cpaper cpaper changed the title Fixbug 11 and add a new option --json Fixbug #11 and add a new option --json Oct 8, 2019
Copy link
Owner

@X140Yu X140Yu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交!提了几处小问题

Comment on lines 43 to +44
else
pp result
if @to_output_json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把这两个合并一下吧


def final_path
d = File.join(Dir.tmpdir, 'pod')
if not Dir.exist?(d)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use unless instead

Comment on lines +69 to +71
f = File.open(template_path)
template = ERB.new(f.read)
f.close
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接用 File.read 就不需要手动 open, close 了

f = File.open(template_path)
template = ERB.new(f.read)
f.close
return template.result(binding)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 可以省掉

@@ -51,14 +46,16 @@
function pageDidLoad() {
loadJSON('index.json', response => {
var actual_JSON = JSON.parse(response);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

帮忙把这个文件里所有的 var 也一起改掉吧,当年年少不知事 =,=

def write_d3js_to_file(path)
json = 'var dependencies = ' + to_d3js_json
File.write(path, json)
return json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omit return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants