Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bjcp-2015-styleguide
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frank Steinberg
bjcp-2015-styleguide
Commits
4e8f0a6f
Commit
4e8f0a6f
authored
5 years ago
by
Frank Steinberg
Browse files
Options
Downloads
Patches
Plain Diff
Improvements to online editor.
parent
8c411c08
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+2
-0
2 additions, 0 deletions
Makefile
web/save.cgi
+84
-6
84 additions, 6 deletions
web/save.cgi
xsl/bjcp-2015-styleguide-merge.xsl
+92
-0
92 additions, 0 deletions
xsl/bjcp-2015-styleguide-merge.xsl
with
178 additions
and
6 deletions
Makefile
+
2
−
0
View file @
4e8f0a6f
...
@@ -49,7 +49,9 @@ check: bjcp-2015-styleguide-orig.xml bjcp-2015-styleguide-de.xml
...
@@ -49,7 +49,9 @@ check: bjcp-2015-styleguide-orig.xml bjcp-2015-styleguide-de.xml
@
xmllint
--noout
--schema
xsd/bjcp-styleguide-2015.xsd bjcp-2015-styleguide-de.xml
@
xmllint
--noout
--schema
xsd/bjcp-styleguide-2015.xsd bjcp-2015-styleguide-de.xml
install
:
bjcp-2015-styleguide-de-edit.html
install
:
bjcp-2015-styleguide-de-edit.html
ssh z
"if [ ! -d /var/www/bjcp-styleguide ] ; then sudo mkdir /var/www/bjcp-styleguide ; sudo chown frank.www-data /var/www/bjcp-styleguide ; sudo chmod u+rwx,g+rwxs /var/www/bjcp-styleguide ; fi ; touch /var/www/bjcp-styleguide/logfile ; mkdir /var/www/bjcp-styleguide/snippets"
scp bjcp-2015-styleguide-de-edit.html web/bjcp-styleguide.css web/edit.css web/edit.js web/pell.css web/pell.js web/save.cgi z:/var/www/bjcp-styleguide/
scp bjcp-2015-styleguide-de-edit.html web/bjcp-styleguide.css web/edit.css web/edit.js web/pell.css web/pell.js web/save.cgi z:/var/www/bjcp-styleguide/
ssh z
"cd /var/www/bjcp-styleguide ; git clone https://github.com/frsteinb/bjcp-2015-styleguide.git ; cd bjcp-2015-styleguide ; make"
clean
:
clean
:
@
rm
-rf
orig
@
rm
-rf
orig
...
...
This diff is collapsed.
Click to expand it.
web/save.cgi
+
84
−
6
View file @
4e8f0a6f
#!/usr/bin/python3
#!/usr/bin/python3
import
os
import
os
import
os.path
import
re
import
sys
import
sys
import
urllib.parse
import
urllib.parse
import
codecs
import
time
import
datetime
DIR
=
"
/var/www/bjcp-styleguide
"
LOGFILE
=
"
%s/logfile
"
%
DIR
SNIPPETDIR
=
"
/var/www/bjcp-styleguide/snippets
"
REPODIR
=
"
/var/www/bjcp-styleguide/bjcp-2015-styleguide
"
LANG
=
"
de
"
def
log
(
msg
):
time
=
datetime
.
datetime
.
now
().
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
f
=
open
(
LOGFILE
,
"
a+
"
)
f
.
write
(
"
%s %s
\n
"
%
(
time
,
msg
))
f
.
close
()
print
(
"
Content-Type: text/plain
"
)
print
(
"
Content-Type: text/plain
"
)
print
()
print
()
...
@@ -12,18 +33,32 @@ if "QUERY_STRING" in os.environ:
...
@@ -12,18 +33,32 @@ if "QUERY_STRING" in os.environ:
else
:
else
:
form
=
{}
form
=
{}
level
=
None
if
"
id
"
in
form
:
if
"
id
"
in
form
:
id
=
form
[
"
id
"
][
0
]
id
=
form
[
"
id
"
][
0
]
id
=
re
.
sub
(
r
'
[^a-zA-Z0-9\-]+
'
,
''
,
id
)
if
re
.
match
(
r
'
^[0-9]+$
'
,
id
):
level
=
1
elif
re
.
match
(
r
'
^[0-9]+[A-Z]-.*$
'
,
id
):
level
=
3
id1
=
re
.
sub
(
r
'
^([0-9]+)[A-Z]-.*$
'
,
r
'
\1
'
,
id
)
id2
=
re
.
sub
(
r
'
^([0-9]+[A-Z])-.*$
'
,
r
'
\1
'
,
id
)
else
:
level
=
2
id1
=
re
.
sub
(
r
'
^([0-9]+).*$
'
,
r
'
\1
'
,
id
)
else
:
else
:
id
=
"
unknown
"
id
=
"
unknown
"
if
"
elem
"
in
form
:
if
"
elem
"
in
form
:
elem
=
form
[
"
elem
"
][
0
]
elem
=
form
[
"
elem
"
][
0
]
elem
=
re
.
sub
(
'
[^a-z\-]+
'
,
''
,
elem
)
else
:
else
:
elem
=
"
unknown
"
elem
=
"
unknown
"
if
"
user
"
in
form
:
if
"
user
"
in
form
:
user
=
form
[
"
user
"
][
0
]
user
=
form
[
"
user
"
][
0
]
elem
=
re
.
sub
(
'
[^a-zA-Z0-9_+@\-]+
'
,
''
,
elem
)
else
:
else
:
user
=
"
unknown
"
user
=
"
unknown
"
...
@@ -34,15 +69,58 @@ else:
...
@@ -34,15 +69,58 @@ else:
data
=
sys
.
stdin
.
buffer
.
read
()
data
=
sys
.
stdin
.
buffer
.
read
()
len
=
len
(
data
)
data
=
data
.
decode
(
"
utf-8
"
)
msg
=
"
received %d bytes for id %s elem %s from %s by %s
"
%
(
len
(
data
),
id
,
elem
,
addr
,
user
)
time
=
datetime
.
datetime
.
now
().
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
filename
=
"
snippet-%s-%d.xml
"
%
(
time
.
replace
(
"
"
,
"
-
"
).
replace
(
"
:
"
,
"
-
"
),
os
.
getpid
())
snippetfilename
=
"
%s/%s
"
%
(
SNIPPETDIR
,
filename
)
msg
=
"
received %d bytes for id %s elem %s from %s by %s to %s
"
%
(
len
,
id
,
elem
,
addr
,
user
,
filename
)
f
=
open
(
"
/var/log/bjcp-styleguide/log
"
,
"
w+
"
)
log
(
msg
)
f
.
write
(
"
%s
\n
"
%
msg
)
f
.
close
()
f
=
open
(
"
/var/log/bjcp-styleguide/data
"
,
"
wb
"
)
f
=
codecs
.
open
(
snippetfilename
,
"
w
"
,
"
utf-8
"
)
f
.
write
(
data
)
f
.
write
(
'
<?xml version=
"
1.0
"
encoding=
"
UTF-8
"
?>
\n
'
)
f
.
write
(
'
<styleguide xmlns=
"
http://heimbrauconvention.de/bjcp-styleguide/2015
"
>
\n
'
)
f
.
write
(
'
<!-- snippet supplied by %s from %s at %s -->
\n
'
%
(
user
,
addr
,
time
))
if
level
==
1
:
f
.
write
(
'
<category id=
"
%s
"
>
\n
'
%
id
)
f
.
write
(
'
<%s>%s</%s>
\n
'
%
(
elem
,
data
,
elem
))
f
.
write
(
'
</category>
\n
'
)
elif
level
==
2
:
f
.
write
(
'
<category id=
"
%s
"
>
\n
'
%
id1
)
f
.
write
(
'
<subcategory id=
"
%s
"
>
\n
'
%
id
)
f
.
write
(
'
<%s>%s</%s>
\n
'
%
(
elem
,
data
,
elem
))
f
.
write
(
'
</subcategory>
\n
'
)
f
.
write
(
'
</category>
\n
'
)
elif
level
==
3
:
f
.
write
(
'
<category id=
"
%s
"
>
\n
'
%
id1
)
f
.
write
(
'
<subcategory id=
"
%s
"
>
\n
'
%
id2
)
f
.
write
(
'
<subcategory id=
"
%s
"
>
\n
'
%
id
)
f
.
write
(
'
<%s>%s</%s>
\n
'
%
(
elem
,
data
,
elem
))
f
.
write
(
'
</subcategory>
\n
'
)
f
.
write
(
'
</subcategory>
\n
'
)
f
.
write
(
'
</category>
\n
'
)
else
:
f
.
write
(
'
<!-- ID %s could not be parsed -->
\n
'
)
f
.
write
(
'
</styleguide>
\n
'
)
f
.
close
()
f
.
close
()
origfilename
=
"
%s/orig/%s.xml
"
%
(
REPODIR
,
id
)
translatedfilename
=
"
%s/%s/%s.xml
"
%
(
REPODIR
,
LANG
,
id
)
if
os
.
path
.
isfile
(
translatedfilename
):
inputfilename
=
translatedfilename
if
os
.
path
.
isfile
(
origfilename
):
inputfilename
=
origfilename
else
:
log
(
"
neither orig file %s nor translated file %s for id %s exists
"
%
(
origfilename
,
translatedfilename
,
id
))
inputfilename
=
None
if
inputfilename
:
cmd
=
"
xsltproc --stringparam snippet %s %s/xsl/bjcp-2015-styleguide-merge.xsl %s > %s
"
%
(
snippetfilename
,
REPODIR
,
inputfilename
,
translatedfilename
)
log
(
cmd
)
os
.
system
(
cmd
)
# TODO: parse, create response, show error response on client, write xml on server, git commit,
# TODO: parse, create response, show error response on client, write xml on server, git commit,
This diff is collapsed.
Click to expand it.
xsl/bjcp-2015-styleguide-merge.xsl
0 → 100644
+
92
−
0
View file @
4e8f0a6f
<?xml version="1.0"?>
<xsl:stylesheet
version=
"1.0"
xmlns=
"http://heimbrauconvention.de/bjcp-styleguide/2015"
xmlns:bjcp=
"http://heimbrauconvention.de/bjcp-styleguide/2015"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns:exsl=
"http://exslt.org/common"
xmlns:dyn=
"http://exslt.org/dynamic"
extension-element-prefixes=
"exsl dyn"
>
<xsl:param
name=
"snippet"
></xsl:param>
<xsl:output
method=
"xml"
version=
"1.0"
encoding=
"UTF-8"
indent=
"yes"
/>
<xsl:variable
name=
"snippetid"
>
<xsl:choose>
<xsl:when
test=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category/bjcp:subcategory/bjcp:subcategory"
>
<xsl:value-of
select=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category/bjcp:subcategory/bjcp:subcategory[@id]/@id"
/>
</xsl:when>
<xsl:when
test=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category/bjcp:subcategory"
>
<xsl:value-of
select=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category/bjcp:subcategory[@id]/@id"
/>
</xsl:when>
<xsl:when
test=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category"
>
<xsl:value-of
select=
"document(concat('../',$snippet))/bjcp:styleguide/bjcp:category[@id]/@id"
/>
</xsl:when>
<xsl:otherwise>
<xsl:text>
unknown
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable
name=
"snippetnode"
select=
"document(concat('../',$snippet))/bjcp:styleguide//bjcp:*[@id = $snippetid]"
/>
<!-- suppress these tags in translations -->
<xsl:template
match=
"bjcp:tags|bjcp:specs"
>
</xsl:template>
<xsl:template
match=
"bjcp:*"
>
<xsl:element
name=
"{local-name(.)}"
>
<xsl:apply-templates
select=
"@*"
/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template
match=
"bjcp:name|bjcp:description|bjcp:overall-impression|bjcp:aroma|bjcp:appearance|bjcp:flavor|bjcp:mouthfeel|bjcp:comments|bjcp:history|bjcp:characteristic-ingredients|bjcp:style-comparison|bjcp:entry-instructions|bjcp:commercial-examples"
>
<xsl:variable
name=
"name"
>
<xsl:value-of
select=
"local-name(.)"
/>
</xsl:variable>
<xsl:element
name=
"{$name}"
>
<xsl:apply-templates
select=
"@*"
/>
<xsl:choose>
<xsl:when
test=
"(../@id = $snippetid) and ($snippetnode/bjcp:*[local-name(.)=$name])"
>
<xsl:apply-templates
select=
"$snippetnode/bjcp:*[local-name(.)=$name]/bjcp:* | $snippetnode/bjcp:*[local-name(.)=$name]/text()"
/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<xsl:template
match=
"@*"
>
<xsl:copy>
<xsl:apply-templates
select=
"@*"
/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template
match=
"text()"
>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment