둘러보기 메뉴
검색
바뀐글
임의글
개인 도구
가입하기
로그인
도움말
도움말
질문게시판
자주 묻는 질문
커뮤니티
실시간 채팅방
가입인사게시판
자유게시판
뉴스게시판
제재안게시판
최근 토론
페미위키
공지사항
개선 요청
바뀐글
임의글
파일 올리기
다면 분류 목록
특수 문서 목록
모듈:FemiwikiBlog 문서 원본 보기
이름공간
모듈
토론
주시
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보
위키베이스 항목
행위
보기
읽기
원본 보기
역사 보기
←
모듈:FemiwikiBlog
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요.
요청한 명령은 다음 중 하나의 권한을 가진 사용자에게 제한됩니다:
사용자
,
Seeders
.
문서를 고치려면 이메일 인증 절차가 필요합니다.
사용자 환경 설정
에서 이메일 주소를 입력하고 이메일 주소 인증을 해주시기 바랍니다.
문서의 원본을 보거나 복사할 수 있습니다.
local p = {} --- 최근 블로그 포스트들을 보여줍니다. -- @param frame.arg['root'] 포스트들의 공통된 문서 제목 부분, '/'는 포함 안 함. -- @param frame.arg['limit'] 보여줄 최다 포스트 수, 없으면 5 -- @return string wikitext function p.renderPosts( frame ) local limit = tonumber( frame.args['limit'] ) or 5; local titleText = frame.args['root'] local lastId = tonumber( frame:expandTemplate{ title = titleText, args = { ['find-last-id'] = 1 } } ) local posts = '' local count = 1; for id=lastId, 1, -1 do titleText = frame.args['root'] .. '/' .. id if mw.title.new( titleText ).exists then posts = posts .. frame:expandTemplate{ title = titleText } count = count + 1 if ( count > limit ) then break end end end local ul = mw.html.create( 'ul' ):addClass( 'blog-posts' ):wikitext( posts ) return tostring( ul ) end --- 마지막 포스트의 Id를 찾습니다. -- @param frame.args['root'] 포스트들의 공통된 문서 제목 부분, '/'는 포함 안 함. -- @param frame.args['approximate-number-of-posts'] ID에 대해 순차탐색을 시작할 수. -- 해당 ID에 이미 포스트가 있다면 증가하면서 순차탐색을, -- 없을 경우 감소시키면서 순차탐색을 하며, -- 0일 경우 0부터 1씩 증가하면서 찾습니다. -- @return number 마지막 포스트의 id function p.findLastId( frame ) local root = frame.args['root'] local start = tonumber( frame.args['approximate-number-of-posts'] ) or 0 local limit = 20 if root == nil then error('root is must declared') end if start == 0 then for id=start, start + limit, 1 do local titleText = frame.args['root'] .. '/' .. id if not mw.title.new( titleText ).exists then return id - 1 end end error("last id was not found") else local titleText = frame.args['root'] .. '/' .. start -- /start 문서가 이미 있다면 어디까지 있는지 증가하면서 순차탐색합니다. if mw.title.new( titleText ).exists then for id=start + 1, start + limit, 1 do local titleText = frame.args['root'] .. '/' .. id if not mw.title.new( titleText ).exists then return id - 1 end end error("last id was not found") -- /start 문서가 아직 없다면 어디까지 없는지 감소하면서 순차탐색합니다. else for id=start -1, 1, -1 do local titleText = frame.args['root'] .. '/' .. id if mw.title.new( titleText ).exists then return id end end return 0 end end end return p
이 문서에서 사용한 틀:
모듈:FemiwikiBlog/설명문서
(
원본 보기
)
모듈:FemiwikiBlog
문서로 돌아갑니다.
다른 언어