Przeglądaj źródła

username 문법 추가

https://github.com/openNAMU/openNAMU/issues/2104
잉여개발기 (SPDV) 2 lat temu
rodzic
commit
0022c452d9

+ 1 - 1
route/tool/func.py

@@ -1058,7 +1058,7 @@ def wiki_css(data):
     data_css = ''
     data_css_dark = ''
 
-    data_css_ver = '215'
+    data_css_ver = '216'
     data_css_ver = '.cache_v' + data_css_ver
 
     if 'main_css' in global_wiki_set:

+ 25 - 0
route/tool/func_render_namumark.py

@@ -604,6 +604,30 @@ class class_do_render_namumark:
 
                 data_name = self.get_tool_data_storage('<span id="' + main_text + '">', '</span>', match_org.group(0))
 
+                return '<' + data_name + '></' + data_name + '>'
+            elif name_data == 'username':
+                data = re.findall(macro_split_regex, match[1])
+
+                # get option
+                user_name = ''
+                render = 1
+                for for_a in data:
+                    data_sub = re.search(macro_split_sub_regex, for_a)
+                    if data_sub:
+                        data_sub = data_sub.groups()
+                        data_sub = [data_sub[0].lower(), data_sub[1]]
+
+                        if data_sub[0] == 'load_name':
+                            if data_sub[1] == '1':
+                                user_name = self.ip
+                        elif data_sub[0] == 'render':
+                            if data_sub[1] == '0':
+                                render = 0
+                    else:
+                        user_name = for_a
+
+                data_name = self.get_tool_data_storage('<span class="' + ('opennamu_render_ip' if render == 1 else '') + '">' + user_name + '</span>', '', match_org.group(0))
+
                 return '<' + data_name + '></' + data_name + '>'
             elif name_data == 'timeif':
                 data = re.findall(macro_split_regex, match[1])
@@ -2329,6 +2353,7 @@ class class_do_render_namumark:
             if(window.location.hash !== '' && document.getElementById(window.location.hash.replace(/^#/, ''))) {
                 document.getElementById(window.location.hash.replace(/^#/, '')).focus();
             }\n
+            opennamu_do_ip_render();\n
         '''
 
     def __call__(self):

+ 18 - 78
views/main_css/js/func/func.js

@@ -1,83 +1,5 @@
 "use strict";
 
-// https://css-tricks.com/how-to-animate-the-details-element/
-class Accordion {
-    constructor(el) {
-        this.el = el;
-        this.summary = el.querySelector('summary');
-        this.content = el.querySelector('.opennamu_folding');
-    
-        this.animation = null;
-        this.isClosing = false;
-        this.isExpanding = false;
-        this.summary.addEventListener('click', (e) => this.onClick(e));
-    }
-  
-    onClick(e) {
-        e.preventDefault();
-        this.el.style.overflow = 'hidden';
-        if(this.isClosing || !this.el.open) {
-            this.open();
-        } else if(this.isExpanding || this.el.open) {
-            this.shrink();
-        }
-    }
-  
-    shrink() {
-        this.isClosing = true;
-        
-        const startHeight = `${this.el.offsetHeight}px`;
-        const endHeight = `${this.summary.offsetHeight}px`;
-        
-        if(this.animation) {
-            this.animation.cancel();
-        }
-        
-        this.animation = this.el.animate({
-            height: [startHeight, endHeight]
-        }, {
-            duration: 200,
-            easing: 'ease-out'
-        });
-        
-        this.animation.onfinish = () => this.onAnimationFinish(false);
-        this.animation.oncancel = () => this.isClosing = false;
-    }
-  
-    open() {
-        this.el.style.height = `${this.el.offsetHeight}px`;
-        this.el.open = true;
-        window.requestAnimationFrame(() => this.expand());
-    }
-  
-    expand() {
-        this.isExpanding = true;
-        const startHeight = `${this.el.offsetHeight}px`;
-        const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;
-        
-        if(this.animation) {
-            this.animation.cancel();
-        }
-        
-        this.animation = this.el.animate({
-            height: [startHeight, endHeight]
-        }, {
-            duration: 200,
-            easing: 'ease-out'
-        });
-        this.animation.onfinish = () => this.onAnimationFinish(true);
-        this.animation.oncancel = () => this.isExpanding = false;
-    }
-  
-    onAnimationFinish(open) {
-        this.el.open = open;
-        this.animation = null;
-        this.isClosing = false;
-        this.isExpanding = false;
-        this.el.style.height = this.el.style.overflow = '';
-    }
-}
-
 function opennamu_do_id_check(data) {
     if(data.match(/\.|\:/)) {
         return 0;
@@ -86,6 +8,24 @@ function opennamu_do_id_check(data) {
     }
 }
 
+function opennamu_do_ip_render() {
+    let temp = {};
+    for(let for_a = 0; for_a < document.getElementsByClassName('opennamu_render_ip').length; for_a++) {
+        let ip = document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML.replace(/&amp;/g, '&');
+
+        if(temp[ip]) {
+            document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML = temp[ip];
+        } else {
+            fetch('/api/ip/' + opennamu_do_url_encode(ip)).then(function(res) {
+                return res.json();
+            }).then(function(data) {
+                document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML = data["data"];
+                temp[ip] = data["data"];
+            });
+        }
+    }
+}
+
 function opennamu_do_url_encode(data) {
     return encodeURIComponent(data);
 }

+ 78 - 0
views/main_css/js/route/render.js

@@ -1,5 +1,83 @@
 "use strict";
 
+// https://css-tricks.com/how-to-animate-the-details-element/
+class Accordion {
+    constructor(el) {
+        this.el = el;
+        this.summary = el.querySelector('summary');
+        this.content = el.querySelector('.opennamu_folding');
+    
+        this.animation = null;
+        this.isClosing = false;
+        this.isExpanding = false;
+        this.summary.addEventListener('click', (e) => this.onClick(e));
+    }
+  
+    onClick(e) {
+        e.preventDefault();
+        this.el.style.overflow = 'hidden';
+        if(this.isClosing || !this.el.open) {
+            this.open();
+        } else if(this.isExpanding || this.el.open) {
+            this.shrink();
+        }
+    }
+  
+    shrink() {
+        this.isClosing = true;
+        
+        const startHeight = `${this.el.offsetHeight}px`;
+        const endHeight = `${this.summary.offsetHeight}px`;
+        
+        if(this.animation) {
+            this.animation.cancel();
+        }
+        
+        this.animation = this.el.animate({
+            height: [startHeight, endHeight]
+        }, {
+            duration: 200,
+            easing: 'ease-out'
+        });
+        
+        this.animation.onfinish = () => this.onAnimationFinish(false);
+        this.animation.oncancel = () => this.isClosing = false;
+    }
+  
+    open() {
+        this.el.style.height = `${this.el.offsetHeight}px`;
+        this.el.open = true;
+        window.requestAnimationFrame(() => this.expand());
+    }
+  
+    expand() {
+        this.isExpanding = true;
+        const startHeight = `${this.el.offsetHeight}px`;
+        const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;
+        
+        if(this.animation) {
+            this.animation.cancel();
+        }
+        
+        this.animation = this.el.animate({
+            height: [startHeight, endHeight]
+        }, {
+            duration: 200,
+            easing: 'ease-out'
+        });
+        this.animation.onfinish = () => this.onAnimationFinish(true);
+        this.animation.oncancel = () => this.isExpanding = false;
+    }
+  
+    onAnimationFinish(open) {
+        this.el.open = open;
+        this.animation = null;
+        this.isClosing = false;
+        this.isExpanding = false;
+        this.el.style.height = this.el.style.overflow = '';
+    }
+}
+
 function opennamu_heading_folding(data, element = '') {
     let fol = document.getElementById(data);
     if(fol.style.display === '' || fol.style.display === 'inline-block' || fol.style.display === 'block') {