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

repos changes #2

Open
1 of 3 tasks
Riajyuu opened this issue Jun 2, 2017 · 2 comments
Open
1 of 3 tasks

repos changes #2

Riajyuu opened this issue Jun 2, 2017 · 2 comments

Comments

@Riajyuu
Copy link
Contributor

Riajyuu commented Jun 2, 2017

  • source code change: markdown→yaml
  • deployment change: githbook→github pages
  • structure change: any chance?
@Riajyuu
Copy link
Contributor Author

Riajyuu commented Jun 2, 2017

experimental repo at https://github.com/AmazingApps/Amazing-Linux-Apps

@taroxd
Copy link

taroxd commented Jun 2, 2017

YAML data for test: https://github.com/AmazingApps/Amazing-Windows-Apps-YAML-test

current YAML format (all the fields can be in any order):

- name: App name
  icon: 
  # No 'open source' here, because it is described in more detail below
  - free
  - portable
  - full_i18n
  - zh_CN
  - zh_HK
  - en_US
  - ja_JP
  - ru_RU
  - cross_platform
  - cli
  open_source: # optional
    license: GPL
    host: GitHub
    url: https://github.com/  # in rare cases, there may be more than one url here, separated by a space.
  homepage: https://github.com/
  download: https://github.com/ # optional
  description: |
    中文说明
    description in English
  warning: English warning   中文警告
  china: true # optional
  strike: true # optional

current code for generating yml from md (ugly ruby code):

require 'yaml'

def parse_icon(line, current)
  icon = []


  add_icon = -> data, png {
    icon.push data if line.include? png
  }
  add_icon.call 'free', 'free'
  add_icon.call 'portable', 'usb'
  add_icon.call 'full_i18n', 'earth-globe'
  add_icon.call 'zh_CN', 'china'
  add_icon.call 'zh_HK', 'hong-kong'
  add_icon.call 'en_US', 'united-states'
  add_icon.call 'ja_JP', 'japan'
  add_icon.call 'ru_RU', 'russia'
  add_icon.call 'cross_platform', 'platform'
  add_icon.call 'cli', 'command'

  current['icon'] = icon
  if line =~ /open-source-icon.png *"([^@:]+)@([^@:]+): *(.+)"/
    current["open_source"] = {
      "license" => $1,
      "host" => $2,
      "url" => $3
    }
  end
end

%w(
audio
chat-client
compression
configuration
customization
data-recovery
dev-tools
downloader
ebooks
efficiency
emails
files
games
hardwares
images
internet
online-storage
practicals
productivity
security
system
terminal
text-editor
video
).each do |f|
  src = File.read 'path/to/Amazing-Windows-Apps/' + f + '.md', encoding: Encoding::UTF_8
  result = []
  current = nil
  src.each_line do |line|
    next if line.chomp.empty?
    if line.start_with?('###')
      if line =~ /^### +\[(.+?)\]\((.+?)\)/
        current = {}
        result.push current
        current["name"] = $1
        current["homepage"] = $2

        parse_icon(line, current)
      elsif line =~ /^### +([^!]+) +\!/
        current = {}
        result.push current
        current["name"] = $1

        parse_icon(line, current)
      end
      if line =~ /^######.+?Site\]\((.+?)\).+Page\]\((.+?)\)/
        current["homepage"] = $1
        current["download"] = $2
      end

      if line.include? '⚠'
        current['warning'] ||= String.new
        current['warning'] << line[(line.index('⚠') + 1)..-1]
      end

    else
      next if current.nil?
      current["description"] ||= String.new
      current["description"] << line
    end
  end

  File.open('output/path/' + f + '.yml', 'wb') do |fw|
    fw.puts result.to_yaml
  end
end

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

No branches or pull requests

2 participants