Science Score: 18.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (2.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

开源书籍

Basic Info
Statistics
  • Stars: 7
  • Watchers: 12
  • Forks: 6
  • Open Issues: 0
  • Releases: 0
Created almost 4 years ago · Last pushed over 3 years ago
Metadata Files
Readme License Citation

README.md

编译开源书籍

本书的内容使用 mdbook 进行编写,并通过开源社发布。

安装 rust

```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

访问 https://www.rust-lang.org/tools/install 下载 rustup 并安装

```

安装 mdbook

```bash cargo install mdbook cargo install mdbook-echarts

cargo install --git https://github.com/rust-lang/mdBook.git mdbook cargo install --git https://github.com/zhuangbiaowei/mdbook-echarts mdbook-echarts ```


编译开源书籍

bash git clone https://github.com/kaiyuanshe/oss-book cd oss-book mdbook build mdbook serve

在浏览器中打开 http://localhost:3000 访问开源书籍的内容页面。

Owner

  • Name: 开源社
  • Login: kaiyuanshe
  • Kind: organization
  • Email: contact@kaiyuanshe.org
  • Location: China

成立于2014年,以 “立足中国、贡献全球” 为愿景,依 “贡献、共识、共治” 原则所组成,是最早以 “开源治理、国际接轨、社区发展、开源项目” 为使命的开源社区联合体。2017年,开源社转型为完全由个人成员组成,链接了数万名开源人,集聚了上千名社区成员及志愿者、海内外数百位讲师,合作了近百家赞助、媒体、社区伙伴。

Citation (citation.rb)

require 'json'
require 'tomlrb'
require 'kramdown'
require 'fileutils'

REPOS = {}

def get_url(item)
    name , path, lines = item.split(":")
    log = `git -C repos/#{name} log -1 --oneline`
    sha = log[0..6]
    value = REPOS[name]
    url = value["repo"]+"/blob/"+sha+"/"+path+".md?plain=1"
    if lines
        unless lines.include?("-")
            url = url + "#L" + lines
        else
            start, eof = lines.split("-")
            url = url + "#L" + start + "-L" + eof
        end
    end
    return url
end

def move_image(name, path, md)
    html = Kramdown::Document.new(md).to_html
    html.scan(/\<img.+\>/).each do |str|
        str.scan(/src=\"(\S+)\"/).each do |srcs|
            srcs.each do |src|
                source =  File.expand_path("./repos/#{name}/#{path.split("/")[0..-2].join("/")}/#{src}")
                if File.exists? source
                    dist = File.expand_path("./src/#{src}")
                    dist_dir = File.expand_path("src/"+src.split("/")[0..-2].join("/"))
                    `mkdir -p #{dist_dir}` unless Dir.exists?(dist_dir)
                    FileUtils.copy(source, dist)
                end
            end
        end
    end
end

def replace_citation(content)
    citation_index = 0
    citation_list = ""
    content.gsub!(/\(\(.*\)\)/) do |item|
        item = item[2..-3]
        name , path, lines = item.split(":")
        md = File.read("./repos/#{name}/#{path}.md")
        if lines
            unless lines.include?("-")
                md = md.split("\n")[lines.to_i-1]
            else
                start, eof = lines.split("-")
                md = md.split("\n")[start.to_i-1, eof.to_i-1].join("\n")
            end
        end
        move_image(name, path, md)
        citation_index += 1
        citation_list = citation_list + "[^#{citation_index}]: [#{item}](#{get_url(item)})\n\n"
        md + "[^#{citation_index}]"
    end
    content = content + "\n---\n" + citation_list
    return content
end

def list_chapter(arr)
    arr.each do |item|
        chapter = item["Chapter"]
        chapter["content"] = replace_citation(chapter["content"])
        if File.exists?("./src/"+chapter["path"])
            File.write("./src/"+chapter["path"], chapter["content"])
        end
        if chapter["sub_items"]
            list_chapter(chapter["sub_items"])
        end
    end
end

if ARGV.size > 0
    if ARGV[0]=="supports"
        exit()
    end
end

`mkdir repos` unless Dir.exists?("./repos")
obj = Tomlrb.load_file("book.toml")
obj["citation"].each do |key, value|
    STDERR.puts key
    REPOS[key] = value
    unless Dir.exists?("./repos/#{key}")
        `git clone -b #{value["branch"]} #{value["repo"]} repos/#{key}`
    else
        `git -C repos/#{key} checkout #{value["branch"]}`
        `git -C repos/#{key} pull`
    end
    if value["ref"]
        `git -C repos/#{key} checkout #{value["ref"]}`
    end
end

str = STDIN.read
context, book = JSON.parse(str)
list_chapter(book["sections"])
STDOUT.puts JSON.dump(book)

GitHub Events

Total
  • Watch event: 1
  • Pull request event: 2
  • Fork event: 1
Last Year
  • Watch event: 1
  • Pull request event: 2
  • Fork event: 1

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • wangyantong2000 (2)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/gh-pages.yml actions
  • actions/checkout v2 composite
  • actions/setup-node v3.4.1 composite
  • actions/setup-ruby v1 composite
  • peaceiris/actions-gh-pages v3 composite
  • peaceiris/actions-mdbook v1 composite