Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit674c26e

Browse files
authored
feat(editor-export): editor people && re-org (#303)
* feat(editor-export): people block basic func done* chore: fmt* refactor(editor-people): re-org codebase* refactor(editor-people): switch UI/UX done* refactor(editor): use@Class[xxx] style, more readable* refactor(editor-people): add some test* refactor(editor-test): use common mock_image(s)* refactor(editor-test): rm unsed class vars* fix(ci): use offical elixir action
1 parentd035a4b commit674c26e

File tree

26 files changed

+707
-222
lines changed

26 files changed

+707
-222
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
configFile:.commitlintrc.js
3333
-name:Set up Elixir and OTP
34-
uses:actions/setup-elixir@v1
34+
uses:erlef/setup-elixir@v1
3535
with:
3636
elixir-version:"1.10.3"# Define the elixir version [required]
3737
otp-version:"22.3"# Define the OTP version [required]

‎config/config.exs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ config :groupher_server, :customization,
6262

6363
config:groupher_server,GroupherServerWeb.Gettext,default_locale:"zh_CN",locales:~w(en zh_CN)
6464

65+
config:groupher_server,:cloud_assets,
66+
static_icon:"https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/static"
67+
6568
# config email services
6669
config:groupher_server,:system_emails,
6770
support_email:"coderplanets <support@group.coderplanets.com>",

‎lib/helper/converter/editor_to_html/class.ex‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ defmodule Helper.Converter.EditorToHTML.Class do
1515
"viewer"=>"article-viewer-wrapper",
1616
"unknow_block"=>"unknow-block",
1717
"invalid_block"=>"invalid-block",
18+
"hide"=>"hide",
1819
# header
1920
"header"=>%{
2021
"wrapper"=>"header-wrapper",
@@ -80,6 +81,23 @@ defmodule Helper.Converter.EditorToHTML.Class do
8081
# minimap
8182
"gallery_minimap"=>"gallery-minimap",
8283
"gallery_minimap_image"=>"gallery-minimap-block-image"
84+
},
85+
"people"=>%{
86+
"wrapper"=>"people-wrapper",
87+
# gallery
88+
"gallery_wrapper"=>"gallery-wrapper",
89+
"gallery_previewer_wrapper"=>"gallery-previewer-wrapper",
90+
"gallery_previewer_item"=>"gallery-previewer-item",
91+
"gallery_previewer_active_item"=>"gallery-previewer-item-active",
92+
"gallery_card_wrapper"=>"gallery-card-wrapper",
93+
"gallery_avatar"=>"gallery-avatar",
94+
"gallery_intro"=>"gallery-intro",
95+
"gallery_intro_title"=>"gallery-intro-title",
96+
"gallery_intro_bio"=>"gallery-intro-bio",
97+
"gallery_intro_desc"=>"gallery-intro-desc",
98+
"gallery_social_wrapper"=>"gallery-social-wrapper",
99+
"gallery_social_icon"=>"gallery-social-icon"
100+
## social
83101
}
84102
}
85103
end

‎lib/helper/converter/editor_to_html/frags/header.ex‎

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,32 @@ defmodule Helper.Converter.EditorToHTML.Frags.Header do
1414
@specget(T.editor_header())::T.html()
1515
defget(%{"eyebrowTitle"=>eyebrow_title,"footerTitle"=>footer_title}=data)do
1616
%{"text"=>text,"level"=>level}=data
17-
18-
wrapper_class=@class["wrapper"]
19-
header_class=@class["header"]
20-
eyebrow_class=@class["eyebrow_title"]
21-
footer_class=@class["footer_title"]
22-
2317
anchor_id=Utils.uid(:html,data)
2418

25-
~s(<divpl-s1">#{anchor_id}"pl-s1">#{wrapper_class}">
26-
<divpl-s1">#{eyebrow_class}">#{eyebrow_title}</div>
27-
<h#{level}pl-s1">#{header_class}">#{text}</h#{level}>
28-
<divpl-s1">#{footer_class}">#{footer_title}</div>
19+
~s(<divpl-s1">#{anchor_id}"pl-s1">#{@class["wrapper"]}">
20+
<divpl-s1">#{@class["eyebrow_title"]}">#{eyebrow_title}</div>
21+
<h#{level}pl-s1">#{@class["header"]}">#{text}</h#{level}>
22+
<divpl-s1">#{@class["footer_title"]}">#{footer_title}</div>
2923
</div>)
3024
end
3125

3226
defget(%{"eyebrowTitle"=>eyebrow_title}=data)do
3327
%{"text"=>text,"level"=>level}=data
34-
35-
wrapper_class=@class["wrapper"]
36-
header_class=@class["header"]
37-
eyebrow_class=@class["eyebrow_title"]
38-
3928
anchor_id=Utils.uid(:html,data)
4029

41-
~s(<divpl-s1">#{anchor_id}"pl-s1">#{wrapper_class}">
42-
<divpl-s1">#{eyebrow_class}">#{eyebrow_title}</div>
43-
<h#{level}pl-s1">#{header_class}">#{text}</h#{level}>
30+
~s(<divpl-s1">#{anchor_id}"pl-s1">#{@class["wrapper"]}">
31+
<divpl-s1">#{@class["eyebrow_title"]}">#{eyebrow_title}</div>
32+
<h#{level}pl-s1">#{@class["header"]}">#{text}</h#{level}>
4433
</div>)
4534
end
4635

4736
defget(%{"footerTitle"=>footer_title}=data)do
4837
%{"text"=>text,"level"=>level}=data
49-
50-
wrapper_class=@class["wrapper"]
51-
header_class=@class["header"]
52-
footer_class=@class["footer_title"]
53-
5438
anchor_id=Utils.uid(:html,data)
55-
~s(<div id="#{anchor_id}" class="#{wrapper_class}">
56-
<h#{level} class="#{header_class}">#{text}</h#{level}>
57-
<div class="#{footer_class}">#{footer_title}</div>
39+
40+
~s(<div id="#{anchor_id}" class="#{@class["wrapper"]}">
41+
<h#{level} class="#{@class["header"]}">#{text}</h#{level}>
42+
<div class="#{@class["footer_title"]}">#{footer_title}</div>
5843
</div>)
5944
end
6045

‎lib/helper/converter/editor_to_html/frags/image.ex‎

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,21 @@ defmodule Helper.Converter.EditorToHTML.Frags.Image do
2323
wheng_none_empty_str(width)andg_none_empty_str(height)do
2424
caption=get_caption(data)
2525

26-
image_wrapper_class=@class["single_image_wrapper"]
27-
image_class=@class["single_image"]
28-
29-
~s(<div class="#{image_wrapper_class}">
26+
~s(<div class="#{@class["single_image_wrapper"]}">
3027
<a href=#{src} class="glightbox" data-glightbox="type:image;description:#{caption}">
31-
<img class="#{image_class}" style="width:#{width}; height:#{height}" src="#{src}" alt="image" />
28+
<img class="#{@class["single_image"]}" style="width:#{width}; height:#{height}" src="#{
29+
src
30+
}" alt="image" />
3231
</a>
3332
</div>)
3433
end
3534

3635
defget_item(:single,%{"src"=>src}=data)do
3736
caption=get_caption(data)
3837

39-
image_wrapper_class=@class["single_image_wrapper"]
40-
image_class=@class["single_image"]
41-
42-
~s(<div class="#{image_wrapper_class}">
38+
~s(<div class="#{@class["single_image_wrapper"]}">
4339
<a href=#{src} class="glightbox" data-glightbox="type:image;description:#{caption}">
44-
<imgpl-s1">#{image_class}" src="#{src}" alt="image" />
40+
<imgpl-s1">#{@class["single_image"]}" src="#{src}" alt="image" />
4541
</a>
4642
</div>)
4743
end
@@ -50,75 +46,46 @@ defmodule Helper.Converter.EditorToHTML.Frags.Image do
5046
caption=get_caption(data)
5147
# image_wrapper_class = @class["jiugongge-image"]
5248

53-
jiugongge_image_block_class=@class["jiugongge_image_block"]
54-
image_class=@class["jiugongge_image"]
55-
56-
~s(<div class="#{jiugongge_image_block_class}">
49+
~s(<div class="#{@class["jiugongge_image_block"]}">
5750
<a href=#{src} class="glightbox" data-glightbox="type:image;description:#{caption}">
58-
<imgpl-s1">#{image_class}" src="#{src}" alt="image" />
51+
<imgpl-s1">#{@class["jiugongge_image"]}" src="#{src}" alt="image" />
5952
</a>
6053
</div>)
6154
end
6255

6356
defget_item(:gallery,%{"src"=>src,"index"=>index}=data)do
6457
caption=get_caption(data)
6558

66-
gallery_image_block_class=@class["gallery_image_block"]
67-
image_class=@class["gallery_image"]
68-
6959
# IO.inspect(index, label: "index -> ")
70-
~s(<divpl-s1">#{gallery_image_block_class}">
60+
~s(<divpl-s1">#{@class["gallery_image_block"]}">
7161
<a href=#{src} class="glightbox" data-glightbox="type:image;description:#{caption}">
72-
<imgpl-s1">#{image_class}" src="#{src}" alt="image" data-index="#{index}" />
62+
<imgpl-s1">#{@class["gallery_image"]}" src="#{src}" alt="image" data-index="#{index}" />
7363
</a>
7464
</div>)
7565
end
7666

7767
@specget_minimap([T.editor_image_item()])::T.html()
7868
defget_minimap(items)do
79-
wrapper_class=@class["gallery_minimap"]
80-
8169
items_content=
8270
Enum.reduce(items,"",fnitem,acc->
8371
acc<>frag(:minimap_image,item)
8472
end)
8573

86-
~s(<divpl-s1">#{wrapper_class}">
74+
~s(<divpl-s1">#{@class["gallery_minimap"]}">
8775
#{items_content}
8876
</div>)
8977
end
9078

9179
defpfrag(:minimap_image,%{"src"=>src,"index"=>index})do
92-
image_class=@class["gallery_minimap_image"]
93-
94-
~s(<img class="#{image_class}" src="#{src}" data-index="#{index}"/>)
80+
~s(<img class="#{@class["gallery_minimap_image"]}" src="#{src}" data-index="#{index}"/>)
9581
end
9682

9783
defget_caption(%{"caption"=>caption})wheng_none_empty_str(caption),do:caption
9884
defget_caption(_),do:""
9985

10086
defget_caption(:html,%{"caption"=>caption})wheng_none_empty_str(caption)do
101-
image_caption=@class["image_caption"]
102-
~s(<div class="#{image_caption}">#{caption}</div>)
87+
~s(<div class="#{@class["image_caption"]}">#{caption}</div>)
10388
end
10489

10590
defget_caption(:html,_),do:""
106-
107-
# @spec frag(:checkbox, :text, String.t()) :: T.html()
108-
# def frag(:checkbox, :text, text) do
109-
# text_class = @class["checklist_text"]
110-
111-
# ~s(<div class="#{text_class}">
112-
# #{text}
113-
# </div>)
114-
# end
115-
116-
# defp svg(type) do
117-
# # workarround for https://github.com/rrrene/html_sanitize_ex/issues/48
118-
# svg_frag(type) |> String.replace(" viewBox=\"", " viewbox=\"")
119-
# end
120-
121-
# defp svg_frag(:checked) do
122-
# ~s(<svg t="1592049095081" width="20px" height="20px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9783"><path d="M853.333333 256L384 725.333333l-213.333333-213.333333" p-id="9784"></path></svg>)
123-
# end
12491
end

‎lib/helper/converter/editor_to_html/frags/list.ex‎

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
2424
label_frag=ifhide_label,do:"",else:frag(:label,label_type,indent,label)
2525
text_frag=frag(:text,text)
2626

27-
item_class=@class["list_item"]
2827
indent_class=@class["indent_#{indent}"]
2928

30-
~s(<divpl-s1">#{item_class}#{indent_class}">
29+
~s(<divpl-s1">#{@class["list_item"]}#{indent_class}">
3130
#{prefix_frag}
3231
#{label_frag}
3332
#{text_frag}
@@ -49,10 +48,9 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
4948
label_frag=ifhide_label,do:"",else:frag(:label,label_type,indent,label)
5049
text_frag=frag(:text,text)
5150

52-
item_class=@class["list_item"]
5351
indent_class=@class["indent_#{indent}"]
5452

55-
~s(<divpl-s1">#{item_class}#{indent_class}">
53+
~s(<divpl-s1">#{@class["list_item"]}#{indent_class}">
5654
#{prefix_frag}
5755
#{label_frag}
5856
#{text_frag}
@@ -75,10 +73,9 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
7573
label_frag=ifhide_label,do:"",else:frag(:label,label_type,indent,label)
7674
text_frag=frag(:checkbox,:text,text)
7775

78-
item_class=@class["checklist_item"]
7976
indent_class=@class["indent_#{indent}"]
8077

81-
~s(<divpl-s1">#{item_class}#{indent_class}">
78+
~s(<divpl-s1">#{@class["checklist_item"]}#{indent_class}">
8279
#{checkbox_frag}
8380
#{label_frag}
8481
#{text_frag}
@@ -87,57 +84,45 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
8784

8885
@specfrag(:label,T.editor_list_label_type(),T.editor_list_indent(),String.t())::T.html()
8986
deffrag(:label,label_type,indent,label)do
90-
label_class=@class["label"]
9187
label_type_class=@class["label__#{label_type}"]
9288

93-
~s(<divpl-s1">#{label_class}#{label_type_class}" data-index="#{indent}">
89+
~s(<divpl-s1">#{@class["label"]}#{label_type_class}" data-index="#{indent}">
9490
#{label}
9591
</div>)
9692
end
9793

9894
@specfrag(:unorder_list_prefix)::T.html()
9995
deffrag(:unorder_list_prefix)do
100-
unorder_list_prefix_class=@class["unorder_list_prefix"]
101-
102-
~s(<div class="#{unorder_list_prefix_class}"></div>)
96+
~s(<div class="#{@class["unorder_list_prefix"]}"></div>)
10397
end
10498

10599
@specfrag(:order_list_prefix,String.t())::T.html()
106100
deffrag(:order_list_prefix,prefix_index)whenis_binary(prefix_index)do
107-
order_list_prefix_class=@class["order_list_prefix"]
108-
109-
~s(<div class="#{order_list_prefix_class}">#{prefix_index}</div>)
101+
~s(<div class="#{@class["order_list_prefix"]}">#{prefix_index}</div>)
110102
end
111103

112104
@specfrag(:checkbox,Boolean.t())::T.html()
113105
deffrag(:checkbox,checked)whenis_boolean(checked)do
114106
checked_svg=svg(:checked)
115-
116-
checkbox_class=@class["checklist_checkbox"]
117107
checkbox_checked_class=ifchecked,do:@class["checklist_checkbox_checked"],else:""
118-
checkbox_checksign_class=@class["checklist_checksign"]
119108

120-
~s(<divpl-s1">#{checkbox_class}#{checkbox_checked_class}">
121-
<divpl-s1">#{checkbox_checksign_class}">
109+
~s(<divpl-s1">#{@class["checklist_checkbox"]}#{checkbox_checked_class}">
110+
<divpl-s1">#{@class["checklist_checksign"]}">
122111
#{checked_svg}
123112
</div>
124113
</div>)
125114
end
126115

127116
@specfrag(:text,String.t())::T.html()
128117
deffrag(:text,text)whenis_binary(text)do
129-
text_class=@class["text"]
130-
131-
~s(<div class="#{text_class}">
118+
~s(<div class="#{@class["text"]}">
132119
#{text}
133120
</div>)
134121
end
135122

136123
@specfrag(:checkbox,:text,String.t())::T.html()
137124
deffrag(:checkbox,:text,text)do
138-
text_class=@class["checklist_text"]
139-
140-
~s(<div class="#{text_class}">
125+
~s(<div class="#{@class["checklist_text"]}">
141126
#{text}
142127
</div>)
143128
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp