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

Commit4f5638e

Browse files
authored
Merge pull request#92 from minjk-bl/devops
Implementing Apps > PDF
2 parents2ad3369 +fba67af commit4f5638e

File tree

6 files changed

+770
-2
lines changed

6 files changed

+770
-2
lines changed

‎css/common/pdf.css‎

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
.vp-pdf {
2+
position: absolute;
3+
top:0;
4+
left:0;
5+
width:100%;
6+
height:100%;
7+
z-index:1200;
8+
background-color:rgba(0,0,0,.4);
9+
}
10+
.vp-pdf-container {
11+
position: relative;
12+
left:50%;
13+
top:50%;
14+
transform:translate(-50%,-50%);
15+
min-width:470px;
16+
min-height:420px;
17+
width:50%;
18+
height:60%;
19+
background-color: white;
20+
}
21+
.vp-pdf-title {
22+
height:40px;
23+
padding:5px0px5px10px;
24+
background-color:#EEE;
25+
border:1px solid#ddd;;
26+
display: flex;
27+
flex-direction: row;
28+
position: relative;
29+
align-items: center;
30+
font-size: 16px;
31+
font-weight: 700;
32+
}
33+
.vp-pdf-close,
34+
.vp-pdf-popup-close {
35+
position: fixed;
36+
z-index:3;
37+
right:5px;
38+
width:30px;
39+
height:20px;
40+
line-height:20px;
41+
top:10px;
42+
text-align: center;
43+
cursor: pointer;
44+
}
45+
.vp-pdf-body {
46+
width:100%;
47+
height:calc(100%-90px);
48+
padding:10px;
49+
}
50+
.vp-pdf-grid-box {
51+
display: grid;
52+
width:100%;
53+
height:100%;
54+
grid-row-gap:5px;
55+
/* grid-template-rows: 60px calc(100% - 80px); */
56+
/* grid-template-rows: 80px calc(100% - 100px); */
57+
/* grid-template-rows: 80px min-content; */
58+
grid-template-rows:60px140px150px;
59+
}
60+
.vp-pdf-prepare-box {
61+
display: grid;
62+
grid-template-columns:50%50%;
63+
align-items: baseline;
64+
align-content: center;
65+
border:1px solid#E4E4E4;
66+
border-radius:5px;
67+
box-sizing: border-box;
68+
padding:15px;
69+
}
70+
.vp-pdf-link {
71+
color:var(--highlight-color);
72+
}
73+
.vp-pdf-install-btn{
74+
margin-left:7px;
75+
}
76+
.vp-pdf-check-btn {
77+
display: inline-block;
78+
margin-left:5px;
79+
}
80+
.vp-pdf-import-btn {
81+
margin-left:10px;
82+
}
83+
.vp-pdf-show-box {
84+
display: grid;
85+
/* grid-template-rows: min-content min-content; */
86+
grid-row-gap:10px;
87+
border:1px solid#E4E4E4;
88+
border-radius:5px;
89+
box-sizing: border-box;
90+
padding:15px;
91+
}
92+
.vp-pdf-df-box {
93+
display: grid;
94+
grid-template-columns:95px auto;
95+
grid-row-gap:3px;
96+
align-items: baseline;
97+
align-content: space-evenly;
98+
}
99+
.vp-pdf#vp_pdfVariable {
100+
width:62%;
101+
height:30px;
102+
}
103+
.vp-pdf-input {
104+
width:62%;
105+
}
106+
.vp-pdf-run-btn {
107+
width:112px!important;
108+
margin-left:5px;
109+
}
110+
.vp-pdf-preview-box {
111+
display: none;
112+
width:100%;
113+
height:100px;
114+
position: absolute;
115+
bottom:50px;
116+
117+
background:#F7F7F7;
118+
border:0.25px solid#E4E4E4;
119+
padding:10px;
120+
}
121+
/** Buttons */
122+
.vp-pdf-btn-box {
123+
position: relative;
124+
height:50px;
125+
border-top:0.25px solidvar(--border-gray-color);
126+
}
127+
.vp-pdf-btn {
128+
position: absolute;
129+
}
130+
.vp-pdf-btn-preview {
131+
left:15px;
132+
top:9px;
133+
}
134+
.vp-pdf-btn-dataview {
135+
left:105px;
136+
top:9px;
137+
}
138+
.vp-pdf-btn-cancel {
139+
top:9px;
140+
right:105px;
141+
}
142+
.vp-pdf-btn-runadd {
143+
position: absolute;
144+
top:9px;
145+
right:15px;
146+
width: fit-content;
147+
height:30px;
148+
background:#F38504;
149+
border-radius:2px;
150+
}
151+
.vp-pdf-btn-run {
152+
display: inline-block;
153+
width:60px;
154+
border-radius:2px0px0px2px;
155+
border-right:0.25px solidvar(--border-gray-color)!important;
156+
}
157+
.vp-pdf-btn-detail {
158+
display: inline-block;
159+
width:20px;
160+
height:28px;
161+
border-radius:0px2px2px0px;
162+
padding:0;
163+
}
164+
.vp-pdf-detail-box {
165+
display: none;
166+
background: white;
167+
border:0.25px solidvar(--border-gray-color);
168+
position: absolute;
169+
bottom:35px;
170+
right:1px;
171+
width:84px;
172+
height:62px;
173+
text-align: center;
174+
line-height:30px;
175+
}
176+
.vp-pdf-detail-item {
177+
color:var(--font-primary);
178+
}
179+
.vp-pdf-detail-item:hover {
180+
color:var(--font-hightlight);
181+
background:var(--light-gray-color);
182+
}

‎src/api_block/constData.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ define([
287287
constSTR_CODE='code';
288288
constSTR_COMMENT='comment';
289289
constSTR_NODE='node';
290-
constSTR_TEXT='text';
290+
constSTR_TEXT='Markdown';
291291
constSTR_PRINT='print';
292292
constSTR_ELIF='elif';
293293
constSTR_ELSE='else';
@@ -776,6 +776,9 @@ define([
776776
},
777777
'profiling':{
778778
file:'nbextensions/visualpython/src/common/vpProfiling'
779+
},
780+
'pdf':{
781+
file:'nbextensions/visualpython/src/common/vpPDF'
779782
}
780783
}
781784

‎src/api_block/index.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
<imgsrc="/nbextensions/visualpython/resource/apps/apps_white.svg">
9595
<divclass="vp-apiblock-menu-apps-name">Profiling</div>
9696
</div>
97+
<divclass="vp-apiblock-menu-apps-item line3"data-menu="pdf"title="PDF">
98+
<imgsrc="/nbextensions/visualpython/resource/apps/apps_white.svg">
99+
<divclass="vp-apiblock-menu-apps-name">PDF</div>
100+
</div>
97101
<divclass="vp-apiblock-menu-apps-item preparing"data-menu="merge"title="Work In Progress">
98102
<imgsrc="/nbextensions/visualpython/resource/apps/apps_merge.svg">
99103
<divclass="vp-apiblock-menu-apps-name">Merge</div>

‎src/api_block/init.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ define([
266266
case'frame':
267267
case'chart':
268268
case'profiling':
269+
case'pdf':
269270
blockContainer.setSelectBlock(null);
270271
blockContainer.createAppsPage(menu,file,config);
271272
break;
@@ -379,7 +380,7 @@ define([
379380
});
380381

381382
/** Apps Menu Apply event */
382-
$(document).on('subset_run frame_run','#vp_appsCode',function(evt){
383+
$(document).on('subset_run frame_run pdf_run','#vp_appsCode',function(evt){
383384
varcode=evt.code;
384385
vartitle=evt.title;
385386
varstate=evt.state;

‎src/common/pycode.js‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Project Name : Visual Python
3+
* Description : GUI-based Python code generator
4+
* File Name : pycode.js
5+
* Author : Black Logic
6+
* Note : Define constant value
7+
* License : GNU GPLv3 with Visual Python special exception
8+
* Date : 2021. 08. 14
9+
* Change Date :
10+
*/
11+
12+
//============================================================================
13+
// Define constant
14+
//============================================================================
15+
define([
16+
],function(){
17+
'use strict';
18+
19+
//========================================================================
20+
// vpPDF
21+
//========================================================================
22+
constPDF_SHOW='!pip show PyMuPDF nltk'
23+
constPDF_INSTALL1='!pip install PyMuPDF'
24+
constPDF_INSTALL2='!pip install nltk'
25+
26+
constPDF_IMPORT=`import pandas as pd
27+
import fitz
28+
from nltk.tokenize import sent_tokenize`;
29+
30+
constPDF_FUNC=`def vp_pdf_get_sentence(fname_lst):
31+
'''
32+
Get sentence from pdf file by PyMuPDF
33+
'''
34+
df = pd.DataFrame()
35+
for fname in fname_lst:
36+
if fname.split('.')[-1] != 'pdf': continue
37+
try:
38+
doc = fitz.open(fname)
39+
sentence_lst = []
40+
for page in doc:
41+
block_lst = page.getText('blocks')
42+
43+
text_lst = [block[4] for block in block_lst if block[6] == 0]
44+
text = '\\n'.join(text_lst)
45+
46+
sentence_lst.extend([sentence for sentence in sent_tokenize(text)])
47+
48+
doc.close()
49+
except:
50+
continue
51+
52+
df_doc = pd.DataFrame({
53+
'fname': fname,
54+
'sentence': sentence_lst
55+
})
56+
df = pd.concat([df,df_doc])
57+
58+
return df.reset_index().drop('index', axis=1)`;
59+
60+
constPDF_CMD='df = vp_pdf_get_sentence(pdf_lst)\ndf'
61+
62+
63+
64+
//========================================================================
65+
// return value
66+
//========================================================================
67+
return{
68+
PDF_SHOW,
69+
PDF_INSTALL1,
70+
PDF_INSTALL2,
71+
PDF_IMPORT,
72+
PDF_FUNC,
73+
PDF_CMD
74+
};
75+
76+
});/* function, define */
77+
78+
/* End of file */
79+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp