Cherry-pick the changes from dev -- part3

This commit is contained in:
EinfachToll
2018-02-16 18:11:49 +01:00
parent 7d4254a75d
commit 73bda6b9ab
9 changed files with 85 additions and 27 deletions

View File

@ -42,7 +42,7 @@ function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~# '^\d\{4}-\d\d-\d\d'
let links = keys(s:get_diary_links())
let links = map(s:get_diary_files(), 'fnamemodify(v:val, ":t:r")')
" include 'today' into links
if index(links, vimwiki#diary#diary_date_link()) == -1
call add(links, vimwiki#diary#diary_date_link())
@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
return result
endfun "}}}
fun! s:get_diary_links() "{{{
fun! s:get_diary_files() "{{{
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
@ -92,9 +92,7 @@ fun! s:get_diary_links() "{{{
" remove backup files (.wiki~)
call filter(files, 'v:val !~# ''.*\~$''')
let links_with_captions = s:read_captions(files)
return links_with_captions
return files
endfun "}}}
fun! s:group_links(links) "{{{
@ -129,7 +127,9 @@ endfunction "}}}
function! s:format_diary() "{{{
let result = []
let g_files = s:group_links(s:get_diary_links())
let links_with_captions = s:read_captions(s:get_diary_files())
let g_files = s:group_links(links_with_captions)
for year in s:sort(keys(g_files))
call add(result, '')

View File

@ -209,6 +209,19 @@ function! s:save_vimwiki_buffer() "{{{
endif
endfunction "}}}
" get date.
function! s:process_date(placeholders, default_date) "{{{
if !empty(a:placeholders)
for [placeholder, row, idx] in a:placeholders
let [type, param] = placeholder
if type ==# 'date' && !empty(param)
return param
endif
endfor
endif
return a:default_date
endfunction "}}}
" get title.
function! s:process_title(placeholders, default_title) "{{{
if !empty(a:placeholders)
@ -1190,7 +1203,7 @@ function! s:parse_line(line, state) " {{{
" nohtml -- placeholder
if !processed
if line =~# '^\s*%nohtml'
if line =~# '\m^\s*%nohtml\s*$'
let processed = 1
let state.placeholder = ['nohtml']
endif
@ -1198,18 +1211,27 @@ function! s:parse_line(line, state) " {{{
" title -- placeholder
if !processed
if line =~# '^\s*%title'
if line =~# '\m^\s*%title\%(\s.*\)\?$'
let processed = 1
let param = matchstr(line, '^\s*%title\s\zs.*')
let param = matchstr(line, '\m^\s*%title\s\+\zs.*')
let state.placeholder = ['title', param]
endif
endif
" date -- placeholder
if !processed
if line =~# '\m^\s*%date\%(\s.*\)\?$'
let processed = 1
let param = matchstr(line, '\m^\s*%date\s\+\zs.*')
let state.placeholder = ['date', param]
endif
endif
" html template -- placeholder "{{{
if !processed
if line =~# '^\s*%template'
if line =~# '\m^\s*%template\%(\s.*\)\?$'
let processed = 1
let param = matchstr(line, '^\s*%template\s\zs.*')
let param = matchstr(line, '\m^\s*%template\s\+\zs.*')
let state.placeholder = ['template', param]
endif
endif
@ -1483,11 +1505,13 @@ function! s:convert_file(path_html, wikifile) "{{{
call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let html_lines = s:get_html_template(template_name)
" processing template variables (refactor to a function)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')

View File

@ -123,7 +123,7 @@ function! s:normalize_link_syntax_v() " {{{
call setreg('"', link, 'v')
" paste result
norm! `>pgvd
norm! `>""pgvd
finally
call setreg('"', rv, rt)

View File

@ -77,7 +77,7 @@ function! s:populate_global_variables()
let g:vimwiki_global_vars.schemes = 'wiki\d\+,diary,local'
let g:vimwiki_global_vars.web_schemes1 = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'.
\ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp'
let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel'
let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel,data'
let rx_schemes = '\%('.
\ join(split(g:vimwiki_global_vars.schemes, '\s*,\s*'), '\|').'\|'.