aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/rpm/spec
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-22 16:26:41 -0800
committerArmen Kesablyan2012-02-22 16:26:41 -0800
commit0bd1cefea2ab350fad1a891bdc926053b799aafc (patch)
tree962f559fcc02a3dfeb297d59907e40fa153453f3 /imports/codemirror/mode/rpm/spec
parent695bc5082f48dddf66ce31480a4faefc067b38bd (diff)
parent2d2b1af8b5c0d506fe6a1cf65614101fec145970 (diff)
downloadninja-0bd1cefea2ab350fad1a891bdc926053b799aafc.tar.gz
Merge branch 'refs/heads/master' into new-tool-icons
Diffstat (limited to 'imports/codemirror/mode/rpm/spec')
-rwxr-xr-ximports/codemirror/mode/rpm/spec/index.html99
-rwxr-xr-ximports/codemirror/mode/rpm/spec/spec.css5
-rwxr-xr-ximports/codemirror/mode/rpm/spec/spec.js66
3 files changed, 170 insertions, 0 deletions
diff --git a/imports/codemirror/mode/rpm/spec/index.html b/imports/codemirror/mode/rpm/spec/index.html
new file mode 100755
index 00000000..e3bca152
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/index.html
@@ -0,0 +1,99 @@
1<!doctype html>
2<html>
3 <head>
4 <title>CodeMirror: RPM spec mode</title>
5 <link rel="stylesheet" href="../../../lib/codemirror.css">
6 <script src="../../../lib/codemirror.js"></script>
7 <script src="spec.js"></script>
8 <link rel="stylesheet" href="spec.css">
9 <link rel="stylesheet" href="../../../doc/docs.css">
10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11 </head>
12 <body>
13 <h1>CodeMirror: RPM spec mode</h1>
14
15 <div><textarea id="code" name="code">
16#
17# spec file for package minidlna
18#
19# Copyright (c) 2011, Sascha Peilicke <saschpe@gmx.de>
20#
21# All modifications and additions to the file contributed by third parties
22# remain the property of their copyright owners, unless otherwise agreed
23# upon. The license for this file, and modifications and additions to the
24# file, is the same license as for the pristine package itself (unless the
25# license for the pristine package is not an Open Source License, in which
26# case the license is the MIT License). An "Open Source License" is a
27# license that conforms to the Open Source Definition (Version 1.9)
28# published by the Open Source Initiative.
29
30
31Name: libupnp6
32Version: 1.6.13
33Release: 0
34Summary: Portable Universal Plug and Play (UPnP) SDK
35Group: System/Libraries
36License: BSD-3-Clause
37Url: http://sourceforge.net/projects/pupnp/
38Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2
39BuildRoot: %{_tmppath}/%{name}-%{version}-build
40
41%description
42The portable Universal Plug and Play (UPnP) SDK provides support for building
43UPnP-compliant control points, devices, and bridges on several operating
44systems.
45
46%package -n libupnp-devel
47Summary: Portable Universal Plug and Play (UPnP) SDK
48Group: Development/Libraries/C and C++
49Provides: pkgconfig(libupnp)
50Requires: %{name} = %{version}
51
52%description -n libupnp-devel
53The portable Universal Plug and Play (UPnP) SDK provides support for building
54UPnP-compliant control points, devices, and bridges on several operating
55systems.
56
57%prep
58%setup -n libupnp-%{version}
59
60%build
61%configure --disable-static
62make %{?_smp_mflags}
63
64%install
65%makeinstall
66find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
67
68%post -p /sbin/ldconfig
69
70%postun -p /sbin/ldconfig
71
72%files
73%defattr(-,root,root,-)
74%doc ChangeLog NEWS README TODO
75%{_libdir}/libixml.so.*
76%{_libdir}/libthreadutil.so.*
77%{_libdir}/libupnp.so.*
78
79%files -n libupnp-devel
80%defattr(-,root,root,-)
81%{_libdir}/pkgconfig/libupnp.pc
82%{_libdir}/libixml.so
83%{_libdir}/libthreadutil.so
84%{_libdir}/libupnp.so
85%{_includedir}/upnp/
86
87%changelog</textarea></div>
88 <script>
89 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
90 mode: {name: "spec"},
91 lineNumbers: true,
92 indentUnit: 4,
93 matchBrackets: true
94 });
95 </script>
96
97 <p><strong>MIME types defined:</strong> <code>text/x-rpm-spec</code>.</p>
98 </body>
99</html>
diff --git a/imports/codemirror/mode/rpm/spec/spec.css b/imports/codemirror/mode/rpm/spec/spec.css
new file mode 100755
index 00000000..d0a5d430
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/spec.css
@@ -0,0 +1,5 @@
1.cm-s-default span.cm-preamble {color: #b26818; font-weight: bold;}
2.cm-s-default span.cm-macro {color: #b218b2;}
3.cm-s-default span.cm-section {color: green; font-weight: bold;}
4.cm-s-default span.cm-script {color: red;}
5.cm-s-default span.cm-issue {color: yellow;}
diff --git a/imports/codemirror/mode/rpm/spec/spec.js b/imports/codemirror/mode/rpm/spec/spec.js
new file mode 100755
index 00000000..3b5c08c9
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/spec.js
@@ -0,0 +1,66 @@
1// Quick and dirty spec file highlighting
2
3CodeMirror.defineMode("spec", function(config, modeConfig) {
4 var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
5
6 var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
7 var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preun|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
8 var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
9 var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
10 var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
11
12 return {
13 startState: function () {
14 return {
15 controlFlow: false,
16 macroParameters: false,
17 section: false,
18 };
19 },
20 token: function (stream, state) {
21 var ch = stream.peek();
22 if (ch == "#") { stream.skipToEnd(); return "comment"; }
23
24 if (stream.sol()) {
25 if (stream.match(preamble)) { return "preamble"; }
26 if (stream.match(section)) { return "section"; }
27 }
28
29 if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
30 if (stream.match(/^\$\{\w+\}/)) { return "def"; } // Variables like '${RPM_BUILD_ROOT}'
31
32 if (stream.match(control_flow_simple)) { return "keyword"; }
33 if (stream.match(control_flow_complex)) {
34 state.controlFlow = true;
35 return "keyword";
36 }
37 if (state.controlFlow) {
38 if (stream.match(operators)) { return "operator"; }
39 if (stream.match(/^(\d+)/)) { return "number"; }
40 if (stream.eol()) { state.controlFlow = false; }
41 }
42
43 if (stream.match(arch)) { return "number"; }
44
45 // Macros like '%make_install' or '%attr(0775,root,root)'
46 if (stream.match(/^%[\w]+/)) {
47 if (stream.match(/^\(/)) { state.macroParameters = true; }
48 return "macro";
49 }
50 if (state.macroParameters) {
51 if (stream.match(/^\d+/)) { return "number";}
52 if (stream.match(/^\)/)) {
53 state.macroParameters = false;
54 return "macro";
55 }
56 }
57 if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
58
59 //TODO: Include bash script sub-parser (CodeMirror supports that)
60 stream.next();
61 return null;
62 }
63 };
64});
65
66CodeMirror.defineMIME("text/x-rpm-spec", "spec");